Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to open two forms at the same time but i want one to be the Login form and the other is the main form. therefore when the user logs in the form i should be able to access the next form meaning that both forms should appear at the same time but with the login form active and the main behind it and not active.
Also the controls on the main form should be enabled depending on the user that enters the info in the login form.
Thanks in advance

[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 4-Jul-13 2:28am
v3
Comments
OriginalGriff 4-Jul-13 8:28am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

The simplest way to do this is to have the login form as the initial form, and when the login is correct, it then creates an instance of the new form and hides itself:
C#
frmMain fm = new FormMain(string userName);
Hide();
fm.ShowDialog();
Close();
The close at the end exits the application when the user closes the main form.
 
Share this answer
 
Comments
Maciej Los 4-Jul-13 8:56am    
+5
Another solution is to call Login form before initializing Main form ;)
Dispose login form and show main form after username and password are entered on login form[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900