How To Disable a Forms Close Button

  • Thread starter Thread starter John Tyce
  • Start date Start date
J

John Tyce

Does anyone know how I can disable a forms close button in C# without setting the control box value to false? I do not want the user to be able to close the application by clicking the x, but also do not want to take away the ability to minimize the form.
 
The easiest way would be to put in a handler for the form_closing event,
like this...

private void frmMyForm_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}

-James
 
Thanks James.

--
JOHN TYCE
James Divine said:
The easiest way would be to put in a handler for the form_closing event,
like this...

private void frmMyForm_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}

-James
setting the control box value to false? I do not want the user to be able to
close the application by clicking the x, but also do not want to take away
the ability to minimize the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top