private void btnExit_Click(object sender, EventArgs e)
{
this.Close(); //or this.Dispose();
}
What if we also have an event handler for the same button's Click event? Well, the Click event will still be executed, and it will be done first. After the event finishes and returns control to framework, the form will be closed.
By the way, this cannot replace the Application.Exit(). Don't waste your time on using the button's DialogResult property on the main form's Exit button, it won't work.
If you want to know more details about what's underlying, I'll suggest you to read this book: .NET Windows Forms in a Nutshell.
No comments:
Post a Comment