views:

32

answers:

1

Hi,I have a problem and I couldn't solve it.please help me.

I have two windows form in C#,main form and userpassword form. at first I use main form, if user are using username and password,the main form calls userpassword form when user enters correct username and password, can use main form but when the user enter incorrect username and password, she /he can't use main form and now the user want to close the program but in this level user closes program with closeBox,but program opens main form.and it 's problem for me because user couldn't enter correct username and password but now she/he can use main form.

to solve this problem I used application.Exit(); in FormClosed event,my frist problem solved but after that I have another problem.because when I entered correct username and password , when userpassword form closed, all application closed because I use application.Exit(); in FormClosed event.

now what do you suggest to me?

+2  A: 

Use an if statement that checks if they entered the correct username and password, and only call Application.Exit() if they didn't....

Richard Hein
thank you Mr Richard Hein,my program works correct now.
mahnaz
@mahnaz - could you mark @Richard's answer as the accepted one please? Just click the check mark to the left of his answer so it turns green.
Alex Humphrey