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.
This will only disable the X close button:
public partial class Form1 : Form
{
private const int CS_NOCLOSE = 0x200;
protected override CreateParams CreateParams
{
get
{
CreateParams mdiCp = base.CreateParams;
mdiCp.ClassStyle = mdiCp.ClassStyle | CS_NOCLOSE;
return mdiCp;
}
}
public Form1()
{
InitializeComponent();
}
}
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 = 0x200;
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!!!
thanks man …..thanks
Thank you very much………..
Thank you very much Ji that solve my all problem chak de
True, there are comedians that cuss a lot, but you got
to earn that right before you do that. No matter what your field, it
helps to know what you’re good at, but it also helps to recognize what others are good at.
He represented his homeland in four Olympics and is a three-time indoor world champ in the 1500 meters.
To maneuver your ships, just left button phone on the spot.
zynga poker chips at no cost When you be a part of Poker.
Mail, yet others and enable the hacker to have remote device of the account
and it is contents.
Good post. I study something more challenging on completely different blogs everyday. It is going to all the time be stimulating to learn content material from different writers and practice somewhat one thing from their store. I ecfdaakfekdf
excellent… best regards
[…] Disable Close button in Windows form | Codelicious – Sep 07, 2007 · 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 … […]