To disable that little close button in your Windows form, either you can set the ControlBox field in Properties window to False or or add this two line in the contructor:
this.ControlBox = false;
Same goes for Maximize and Minimize boxes. Set it using Properties window or add these lines:
this.MaximizeBox = false; this.MinimizeBox = false;
Simple, huh?
if you disable the control box you automatically lose the icon, minimize and maximize buttons.
simple but incorrect
check http://www.codeproject.com/KB/cs/DisableClose.aspx
for a working solution
Thank you!!! that small works miracles.. the code for making the close inactive.. thank you
private const int
CP_NOCLOSE_BUTTON = 0×200;
protected override CreateParams CreateParams
{
get
{
CreateParams myCp = base.CreateParams;
myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON ;
return myCp;
}
}
Many Thanks for your answer
Thank you! Excellent snippet!
great.. thank you.
Here you can find a perfect solution for this issue. I had the same problem and I fixed it.
http://www.php24hours.com/c-sharp-how-to-disable-the-close-button-t164.html
its realy good thanks dud……
Ohhh Heartily Thank you Very Much…
this is realy good thank you so much
thank you very much!!! its really good
Thats right..
this code has very great work
thanks for it.
I am very happy to get this code
Can we disable these buttons during runtime?
i want know only about cancel button only… other (maximize , minimize) should be visible.. while cancel button should be disable..
thanks
SILENCE WHINERS!!!
The controlbox = false/true works fine!!!