Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I prevent a Form from closing when the user clicks on the close button?

Handle the form's Closing event.

private void Form1_Closing( object sender, CancelEventArgs e ) 
{
  if ( NotOkToClose() ) 
    e.Cancel = true; //don't close 
}

Contributed from George Shepherd's Windows Forms FAQ



Page view counter