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;

           }

       }

Leave a Comment

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