Multiple Forms - How to close the Entire program?

Disasterpiece

Freshman
Joined
Apr 2, 2003
Messages
47
Location
Blacksburg, VA
I have 2 forms - a Login Screen and the main program window.

When the user logs in, I hide the Login form and show the Main form.

My problem is this: When I click the close button in the top right corner on the main form, the Login form is still running (only it's hidden) . How do I get my entire program to close when I hit the X button on the main form?

Thanks :)
 
You could set the Main form as your startup form (thus making it the
form that the running thread depends on and closing it ends the
program), and then show the Login form from the _Load event of
your Main form.
 
Disasterpiece: did you make sure to set the Startup Object to frmMain
(or whatever the form is called)?
 
I will suggest that instead of using a form as a startup object you use SUB MAIN and the Application.Run(), so when you finish with the login screen you can dispose it and load the next form, and when you're done using the app use the Application.Exit(), if you don't use the Application.Exit() your app will keep running

Regards
 
Back
Top