简体   繁体   中英

Remove the Close button in the program's title bar

Goal:
Don't want the user to use the X mark (upper right of the program's screen) to exit the program.

Problem:
Don't know how to remove that icon that allows user to exit the program?

You can set the ControlBox property to false if you don't want this to display. This will also remove the minimize and maximize buttons, mind you.

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

myForm.ControlBox = false;

Apparently I have to have at least 30 characters in my post, so I will say that I am assuming WinForms since you do not specify yourself. Also note that setting this property to false will remove the minimize and maximize buttons as well.

myform.ControlBox = false;

这对我来说

我用它,它为我工作

this.ControlBox = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM