|
-
Oct 18th, 2012, 02:28 AM
#1
Thread Starter
Lively Member
[RESOLVED] Commands on closing a window
Is there a way to execute some lines, when the main window (form1) is closed?
-
Oct 18th, 2012, 02:38 AM
#2
Addicted Member
Re: Commands on closing a window
Regiter closed event or override onclosed method.
Closed/closing event resources:
MSDN: closed event
MSDN: closing event
-
Oct 18th, 2012, 03:21 AM
#3
Re: Commands on closing a window
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.
-
Oct 18th, 2012, 04:46 AM
#4
Thread Starter
Lively Member
Re: Commands on closing a window
Eeh. So how exactly do I write this? Like this:
Code:
public void FormClosing(){
//Lines I want executed
DoStuff();
{
-
Oct 18th, 2012, 06:34 AM
#5
Re: Commands on closing a window
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.
-
Oct 22nd, 2012, 03:38 AM
#6
Thread Starter
Lively Member
Re: Commands on closing a window
Ahh. There it is. Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|