In some condition How can I close second form without open first form?

夙愿已清 提交于 2020-01-25 07:59:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!