问题
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?
回答1:
Use an if statement that checks if they entered the correct username and password, and only call Application.Exit() if they didn't....
来源:https://stackoverflow.com/questions/3589096/in-some-condition-how-can-i-close-second-form-without-open-first-form