Disable Close button in Windows form

September 7, 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 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?

6 Responses to “Disable Close button in Windows form”

  1. Bob Says:

    if you disable the control box you automatically lose the icon, minimize and maximize buttons.

  2. ixi Says:

    simple but incorrect
    check http://www.codeproject.com/KB/cs/DisableClose.aspx
    for a working solution

  3. Franz Says:

    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;
    }
    }

  4. Sireesha Says:

    Many Thanks for your answer

  5. Snattan Says:

    Thank you! Excellent snippet!

  6. pradip Says:

    great.. thank you.


Leave a Reply