Hey guys.
You know the (x) button on the toolbar of your app? I want to add a pice of code right after the it closes the window. How would I do this?
Thanks
Hey guys.
You know the (x) button on the toolbar of your app? I want to add a pice of code right after the it closes the window. How would I do this?
Thanks
You need to add a handler to the FormClosing event. Looking at the CloseReason property of the received FormClosingEventArgs you will know if the form is closing because the user explicitly closed the window or for any other reason.
EDIT: FormClosing will fire before the window is actually closed, and you can cancel this event so that the window is not actually closed. FormClosed, mentioned by Jon, will fire after the window is closed.