3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by buster2209
0

How can this be done?

What about the Application.Exit() function?

I am looking to execute some code when the user presses the 'x' at the top right of the screen

1

How can this be done?

What about the Application.Exit() function?

I am looking to execute some code when the user presses the 'x' at the top right of the screen

private void form1_FormClosing( object sender , FormClosingEventArgs e )
{
       //code
}

Dont forget to attach the event handler. This should go into your Form1.designer.cs

this.FormClosing += new System.Windows.Forms.FormClosingEventHandler( this.Watcher_FormClosing );

EDIT: Yes,this will affect any maner you try to exit the application.

Edited by PierlucSS: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.