Yes, they are fired whenever the form closes which is the only way to know when the Form's close button (The 'X' in the top right corner). But logically if the form's closing because of a button or because of that 'X' in the title bar you would want to run the form's closing code anyways.
the code is basically making sure people dont press the cancel button without saving there stuff. so if the press the cancel button and the system nos there was a change, a message box pop up asking them do they want to save there changes. but if i press the x button it does not save it or no pop up comes up. so in short need both the x button and the cancel button to do the same thing without any conflict
There is a e.CloseReason of FormClosing event that you can look into (if you need a reason). But if your cancel button just close the form you can take it from FormClosing for any reason.
Maybe you can just handle the FormClosing event and have the cancel button close the form without any verification. That way, the FormClosing event will handle all that only once no matter how the form was closed. And you can use the event's arguments to cancel the form closing if the user wants to continue working.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.