Performing some actions before closing winform application in c#

.net, c#, winforms

Solution

Look at the form closing event

Code example VB.Net:

Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

End Sub

and c#

private void Form1_FormClosing(System.Object sender, System.Windows.Forms.FormClosingEventArgs e)
{
}

Problem

I want to perform some actions after the user clicks x button but before the program exits. Is it possible ? If yes then how can i do it ?

Original source

Related problems