Win Coder Win Coder -4 years ago 120
C# Question

Performing some actions before closing winform application in c#

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 ?

Answer Source

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)
{
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download