Is there a way to execute some lines, when the main window (form1) is closed?
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.
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Match Two Game, *NEW* More Random Random Numbers) | C# (*NEW* Match Two Game, *NEW* More Random Random Numbers)
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces
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.
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Match Two Game, *NEW* More Random Random Numbers) | C# (*NEW* Match Two Game, *NEW* More Random Random Numbers)
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces
Ahh. There it is. Thanks!