Possible Duplicate:
How can I close a login form and show the main form without my application closing?
How i can close a 1st form with out closing full the application?
C#. as a example if my 1st form is logging form after enter username and password if they are correct that form should be close and other form need to be open.
I tried this.close() but my full application is exiting :(. After that I tried this.Hide() it works but my form is still running just hidden from UI.
ty
It is actually quite simple. On your Program.cs Main static method use the following code to launch your LoginForm.
var myLoginForm = new LoginForm();
myLoginForm.Show();
Application.Run();
Then from your LoginForm, simply remember to launch your next Form before closing it like this:
var myNextForm = new NextForm();
myNextForm .Show();
this.Close();
If you rather just want to close the application after login fails just do the following:
this.close();
Application.Exit();
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With