Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to close only the main form in vb.net 2010 without terminating the application

Tags:

vb.net

I have a login form which I need to close without the entire application being terminated. I tried using Me.Close() , Me.Hide() as well. The login form is used as the main form as well.

like image 996
Ramila Avatar asked Feb 25 '23 07:02

Ramila


1 Answers

I hope this makes sense....

It sounds like you have a VB.Net project and your Login form is your 'startup form'. When you close that form, your application thinks it is over; but you really want to take action after the Login form is closed.

If you bring up the Properties window for the project, on the Applications Tab you can set the 'Shutdown mode'. The default is when the 'Startup Form Closes'. Change it to 'When the last form closes'.

You can also add Application level events here. http://msdn.microsoft.com/en-us/library/f2bys999(v=vs.80).aspx

If you stick with the way you are going; your Login form is going to have to create another form before it closes or your app will close. You can do that; but it's probably cleaner to move the login logic into the Application Startup Event (see link for more details).

In the startup event you can show the Login screen, get the result, decide if you want to show the main form for your application, etc, etc...

like image 117
Rob P. Avatar answered Feb 26 '23 21:02

Rob P.