You need to generate a FormClosing event handler and add your code to the method that is generated. You can do this by clicking on the form itself and then in the properties window, click the lightning icon to show a list of available events and scroll down until you see FormClosing and double click to the right of this event. This will generate the method in your code-behind program and wire it up for you.
↧