winforms - Form close event in visual studio c# -
i had problem application closing in c#. when hit close button display twice or more times message box. should do?
private void home_formclosed(object sender, formclosedeventargs e) { dialogresult dialog = messagebox.show("are sure want exit ? ", "exit", messageboxbuttons.yesno, messageboxicon.question); if (dialog == dialogresult.yes) { system.windows.forms.application.exit(); } else if (dialog == dialogresult.no) { this.show(); } }
you should use form.formclosing
event instead of formclosed
event. in arguments, find field e.cancel
. setting false, keep form open
Comments
Post a Comment