Remove the Close button in the program title bar.

Purpose:
You do not want the user to use the X icon (in the upper right part of the program screen) to exit the program.

Problem:
Not sure how to remove this icon, which allows the user to exit the program?

+7
source share
5 answers

You can set the ControlBox property to false if you do not want this to be displayed. It will also remove the minimize and maximize buttons, mind you.

I also ask you to consider why you want to remove this button. Sometimes it makes sense to override the OnFormClosing method and, if necessary, set Cancel to true under certain conditions (for example, e.CloseReason == CloseReason.UserClosing ).

+21
source
 myForm.ControlBox = false; 

Apparently, I should have at least 30 characters in my message, so I will say that I accept WinForms since you are not specifying yourself. Also note that setting this property to false will remove the minimize and maximize buttons.

+11
source
 myform.ControlBox = false; 

does it for me

+4
source
+2
source

I used it and its work for me

 this.ControlBox = false; 
+1
source

All Articles