Home » FAQ » WinForms » Form » How do I prevent a Form from closing when the user clicks on the close button on the form’s system menu
Handle the form’s Closing event.
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if( NotOkToClose() ) e.Cancel = true; //don’t close }
Platform BlazorASP.NETWinFormsWPF.NET MAUI
Question *
Answer (Optional)
Email (Optional)
Email address is only for further clarification on your FAQ request. It will not be used for any other purpose.
Please leave this field empty.
Share with