I have winforms app with a login form in which the user enters a user Id and a password. After the correct user id and password is entered, the main form is displayed. When the main form is closed the Login form is still there. I need to get rid of the login form. I haven't been able to figure out how to do this. How do I get to the the Main Form's closing or unloading event? And when I am able to get to this event what do I type to close the login form?
November 8th, 2012, 12:59 PM
sotoasty
Re: Unloading Forms.
When do you show the "Login" form.? Post some code please.
Normally, I would do it like this in the main form Initialization code, or in a controlling class.
dim fLogin as new frmLogin
fLogin.ShowDialog();
isLoggedin = fLogin.WasSuccessfulLogin;
fLogin.Hide();
fLogin = null;
November 8th, 2012, 01:10 PM
viperbyte
Re: Unloading Forms.
Hi Sotoasty.
I was so messed up that I didn't have any code to show. What I ended up doing was hiding the login form. But that alone wasn't good enouh becuase when I closed the main form Visual Studio had the Blue square (stop debugging) icon lit up. The program was still running. So I added a Form_Closing event by using the lighting bolt and added Application.Exit. So that took care of the running program. It all works now. Thanks.