Is there a way to execute some lines, when the main window (form1) is closed?
Printable View
Is there a way to execute some lines, when the main window (form1) is closed?
Regiter closed event or override onclosed method.
Closed/closing event resources:
MSDN: closed event
MSDN: closing event
From .NET 2.0 onwards, you should be using the FormClosing and/or FormClosed events rather than the Closing and Closed events. Note that those ending with "ing" occur before the form closes and allow you to prevent it while those ending with "ed" occur after the form closes.
Eeh. So how exactly do I write this? Like this:
Code:public void FormClosing(){
//Lines I want executed
DoStuff();
{
It's an event, so you handle it like any other event. Select the object whose event you want to handle, open the Properties window, click the Events button and then double-click the event.
Ahh. There it is. Thanks!