|
yes Form2 is Login or Logoff form. and Form1 is main form, but Form1 not a type of mdiparent form. mmh do u have other way of this "Application.Exit()" ?
|
|
|
|
|
well let me give you a quick idea of how you might want to handle an application with a login ability.
So assuming you only have two forms (Form1 for you application stuff, Form2 for you login)
go to your Main function, which you will probably find is your Program Class...
you should have a line of code like
Application.Run(new Form1());
which is always called on start-up. Basically you want to only use that line of code if the login is successful (as decided by your Form2)
First add a class level public static bool to test for login page to be shown or not...
public static bool ShowLogin = true;
so have something like this in your Main class...
while(ShowLogin)
{
Form2 loginForm = new Form2();
if(loginForm.ShowDialog() == DialogResult.OK)
Application.Run(new Form1());
else
ShowLogin = false;
}
Then, in Form2, if the user clicks login and it is succesful use the following code..
this.DialogResult = DialogResult.OK;
this.Close();
else, if the user clicks cancel (which should quit the application) then use this code...
this.DialogResult = DialogResult.Cancel;
this.Close();
now in your Form1 you have your case for 'logoff' or 'exit'. use this code...
case "LOGOFF":
this.Close();
break;
case "EXIT":
Program.ShowLogin = false;
this.Close();
break;
That should now be all you need for a basic login facility for your application
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
You're getting a lot of help here, which is great. But, what you should learn from this is that you need to do some basic study, to understand these VERY basic things. I sure hope no-one is actually going to use this code, the only place you should be in, is a class. And, you should talk to your teacher first, as he can help you better if he knows how stuck you are, and doesn't read other people's code and assume you wrote it.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Want to Verify SSL Certificate for https Link in C#
Any help??
Thanks!!!!!!!!
|
|
|
|
|
Can anybody help upon this??
|
|
|
|
|
Hi All,
I was wondering if someone could point me in the right direction.
I am trying to figure out how to hold multiple object types in a single serialized file.
E.g. If i was wanting to save settings class and a person class in a single serialized file, what would be the best method... also, how can you determine and objects type when deserializing the file.
Thanks in advance,
TF
|
|
|
|
|
string ConfigFile = @"c:\MyConfig.cfg";
int a = 10;
string b = "hi";
DataTable c = new DataTable();
Stream StreamFile = File.Open(ConfigFile, FileMode.CreateNew);
BinaryFormatter binformat = new BinaryFormatter();
binformat.Serialize(StreamFile, a);
binformat.Serialize(StreamFile, b);
binformat.Serialize(StreamFile, c);
StreamFile.Close();
Stream StreamFile = File.Open(ConfigFile, FileMode.Open);
BinaryFormatter binformat = new BinaryFormatter();
int a1 = (int)binformat.Deserialize(StreamFile);
string b1 = (string)binformat.Deserialize(StreamFile);
DataTable c1 = (DataTable)binformat.Deserialize(StreamFile);
StreamFile.Close();
I know nothing , I know nothing ...
|
|
|
|
|
Thanks
Just another quick question which comes from the example;
If you had;
string ConfigFile = @"c:\MyConfig.cfg";
// Save
int a = 1;
int b = 2;
Stream StreamFile = File.Open(ConfigFile, FileMode.CreateNew);
BinaryFormatter binformat = new BinaryFormatter();
binformat.Serialize(StreamFile, a);
binformat.Serialize(StreamFile, b);
StreamFile.Close();
... to create the file, when reading back from the file, how can you indentify which int you would be casting back?
Cheers
TF
|
|
|
|
|
Hi , you are welcome
for your Question :
if you Save your variables like this order ...
int a = 1;
int b = 9;
int c = 3;
then you can read JUST like this
a = (int)Deserlaize ( .... )
b = (int)Deserlaize ( .... )
c = (int)Deserlaize ( .... )
in the same order ,
and the output will be a = 1 , b = 9 , c = 3
in other word you can't read (int b) , with out reading ( int a ) ....
P.S :
I am sorry , I can't found the right word to present this
but may be ( Book1 Above Book2 Above Book3 ) .... you can't get book2 , with out (moving or push away ) book1 ....
I am really sorry for this bad english ....
but if you got the idea , please let me know , I will be happy
I know nothing , I know nothing ...
|
|
|
|
|
Hi guys,
i've created Windows services connecting to web services. but i wz just wondering...
i hv a web service i want utilised by a mobile application. is there anyway i can achieve this? Or rather, is there anything like an equivalent of a windows service on mobile devices?
pls help ASAP.
He who goes for revenge must first dig two graves.
|
|
|
|
|
|
yes. a Windows CE device. Can i connect 2 a web service?
He who goes for revenge must first dig two graves.
|
|
|
|
|
|
plz tel me how to generate crystal report by passing more than one parameter in store procedure
|
|
|
|
|
Have you tried Google and if not bing... they are your friends and if they can't help you what have you tried? Ask a specific question.
|
|
|
|
|
Reading from resource file in C# through access violation exception sometimes
please suggest the needful.
Thanks,
Sachin
|
|
|
|
|
code?
and I didn't understand even half the question
|
|
|
|
|
wait until you see the codez.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
|
I'm guessing "through" should be "throws", although, as you say, without seeing code it'd be hard to guess why.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
cancerion wrote: Reading from resource file in C# through access violation exception sometimes
please suggest the needful.
Hmm.
Ah! It's one of DalekDaves CCCs!
Reading Town in Berkshire
from SQL Reserved Word
resource file To find the rasp again
in C# through C# from beginning to end - CP
access database: DB
violation a crime less serious than a felony
exception an instance that does not conform to a rule or generalization
sometimes please occasionaly makes happy
suggest imply as a possibility
the needful. homeless people.
Got it! It's either:
Antidisestablishmentarianism
or
Gorsafawddacha'idraigodanheddogleddollônpenrhynareurdraethceredigion
but I'm not sure why...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
OriginalGriff wrote: exception an instance that does not conform to a rule or generalization
Even exceptions have to adhere to some rules...
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Ah, but those would be meta-rules...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
PDF virtual printer in c# JurieBurie Just Posted
Hi All
I have a small project that someone asked me to do for them and am struggeling quite a lot to get started.
Could someone please steer me in the right direction.
Here are the requirements:
When you are in app such as word/excel, printer driver must be in printer list.
If you click on driver, dialog box must pop up with email address option & postal address option.
Then it must create a pdf file with unique name inside specific folder.
Must also create a text file which states details punched in i.e. Email or post address with same name as pdf but with dat extention
Example:
C:\pdf-app\23212345432.pdf
C:\pdf-app\23212345432.dat
The .dat contents with email & post option:
Type=email
EmailAddress=carl.vorster@gmail.co.za
Type=post
Address1=Ground Floor
Address2=Augusta building
Address3=Dimension Data Campus
Address4=132 Sloane Street
Code=2055
The .dat contents with post option:
Type=email
EmailAddress=carl.vorster@gmail.co.za
Type=post
Address1=
Address2=
Address3=
Address4=
Code=
The .dat contents with email option:
Type=email
EmailAddress=
Type=post
Address1=Ground Floor
Address2=Augusta building
Address3=Dimension Data Campus
Address4=132 Sloane Street
Code=2055
PLEASE HELP
Jurie
|
|
|
|
|
Help with what?? You haven't said what you're having a problem with.
BTW, you're not pulling this off with a C# solution since it would be insane to try and write a driver with anything other than Visual C++.
|
|
|
|