How do I prevent a Form from closing when the user clicks on the close button on the form’s system menu

Platform: WinForms| Category: Form

Handle the form’s Closing event.

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

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.