Please accept my apologies,if this question is repeatative. I searched existing questions and solutions and I didn’t find exactly solution to my problem.
I’m developing winform application, I have a main form1, which creates form2. Form2 has close button and overidden FormClosing() method to prompt confirmation popup,which works perfectly.
When I want to close form1(which is main application thread) and I want to close all other forms say form2, form3 which were created by form1, without actually prompting confirmation popups for form2, form3. Basically when close form1 it should forcelly close all other forms which were shown from form1, right now it shows all confirmation popups for form2, form3 before exiting application.
I thank for your reply,
regards
skm
You’ll need to pay attention to the e.CloseReason property value that’s passed to you in the FormClosing event. Only prompt the user if e.CloseReason == CloseReason.UserClosing. This also ensures that you don’t display the dialog when the user shuts down Windows. For example:
Do consider always saving changes so the user won’t suffer from unexpected data loss. Say to a temporary file that you re-open when the program starts back up.