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.
 
Back
Top