How To: Hide close button for Windows Form

Several times there is a requirement to hide/disable the close button and to close the Form with a button on the Form to exit the application.

To hide the Close Button on the form we can set ControlBox propertyof the Form to False (by default its set to True)

Published Monday, September 04, 2006 11:53 PM by SushilaSB
Filed under:

Comments

# XP - Programme vor Beendigung sch?tzen? - MCSEboard.de MCSE Forum

Pingback from  XP - Programme vor Beendigung sch?tzen? - MCSEboard.de MCSE Forum

Monday, September 10, 2007 7:06 AM by Edgar Lefgrün

# re: How To: Hide close button for Windows Form

Mich würde das schon interessieren, wo steht es aber?

Friday, February 29, 2008 2:40 PM by James

# re: How To: Hide close button for Windows Form

Well, almost. It hides Maximize, Minimize too.

- James

Tuesday, May 13, 2008 5:46 AM by Einstein

# re: How To: Hide close button for Windows Form

But...it only hides at Design time....At run time it shows the close button...

What should I do..pls?

Sunday, May 25, 2008 3:53 PM by mloefler

# re: How To: Hide close button for Windows Form

In the windows form add this code

      protected override CreateParams CreateParams

       {

           get

           {

               CreateParams param = base.CreateParams;

               param.ClassStyle = param.ClassStyle | 0x200;

               return param;

           }

       }

Tuesday, August 26, 2008 7:55 AM by Styred Developer

# re: How To: Hide close button for Windows Form

CreateParams param = base.CreateParams;

              param.ClassStyle = param.ClassStyle | 0x200;

              return param;

Wednesday, January 07, 2009 12:44 AM by test

# re: How To: Hide close button for Windows Form

go for full screen mode

Wednesday, April 08, 2009 3:30 AM by Shahzad Satti

# re: How To: Hide close button for Windows Form

Good it resolved my problem .

Thanx.

Friday, November 06, 2009 1:17 AM by Prasad Bhagwat

# re: How To: Hide close button for Windows Form

So nice of you.

Good solution.

Thanks a lot :-)

Regards

Prasad

Friday, February 26, 2010 12:15 PM by Acinnina

# re: How To: Hide close button for Windows Form

мне кажется: шикарно..  а82ч

Wednesday, June 09, 2010 1:53 AM by khurshid

# re: How To: Hide close button for Windows Form

Thanks, great...... it worked.

Wednesday, July 21, 2010 5:56 AM by feb

# re: How To: Hide close button for Windows Form

thanks mloefler. :) For VB .NET users.. you can try the code below. I replaced 0x200 with 512 (equivalent of 0x200 in decimal)

   Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams

       Get

           Dim param As CreateParams = MyBase.CreateParams

           param.ClassStyle = param.ClassStyle Or 512

           Return param

       End Get

   End Property

Monday, September 20, 2010 11:53 PM by deepak manila

# re: How To: Hide close button for Windows Form

thnks dude , its really helpful

 protected override CreateParams CreateParams

      {

          get

          {

              CreateParams param = base.CreateParams;

              param.ClassStyle = param.ClassStyle | 0x200;

              return param;

          }

      }

it works !!! :)

Monday, October 04, 2010 12:47 AM by Yakkoob

# re: How To: Hide close button for Windows Form

nice, its working good.

but

after hide the close button,can i enable the close button at run time ? if its posible then, code?

Wednesday, October 13, 2010 4:42 AM by MAngelo

# re: How To: Hide close button for Windows Form

It's working good and it's very useful. Thank You.

Tuesday, January 11, 2011 4:21 AM by lakshmi

# re: How To: Hide close button for Windows Form

i want hide completely or delete that one how?

Thursday, April 21, 2011 5:28 AM by Manjit

# re: How To: Hide close button for Windows Form

This disables but does not hide the close button. Have some very finicky clients who want it HIDDEN ..

Thursday, August 04, 2011 3:49 AM by saranya

# re: How To: Hide close button for Windows Form

Go to properties and select false in control box

Tuesday, August 23, 2011 3:52 PM by rtyecript

# re: How To: Hide close button for Windows Form

I really liked the article, and the very cool blog

Friday, May 11, 2012 1:24 AM by Developer

# re: How To: Hide close button for Windows Form

Hi, This works. But when I open my form at maximized size close, minimize and maximize buttons are coming. how to solve it?

Leave a Comment

(required) 
(required) 
(optional)
(required)