当前位置:网站首页>WinForm remove the close button in the upper right corner
WinForm remove the close button in the upper right corner
2022-07-27 18:56:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack
One way is to display the form's properties in the form's properties panel ControlBox Property is set to false, Or write this in the constructor of the form :
1 public Form1()
2
3 {
4
5 InitializeComponent();
6
7 this.ControlBox = false; // Set that the close button does not appear http://www.cnblogs.com/roucheng/
8
9 }But in doing so , Will be removed along with the minimize and maximize buttons , therefore , If you want to just make the close button inoperative , Then keep it minimized 、 Maximize , Just rewrite the form CreateParams Method :
1 // Disable the close button of the form
2
3 private const int CP_NOCLOSE_BUTTON = 0x200;
4
5 protected override CreateParams CreateParams
6
7 {
8
9 get
10
11 {
12
13 CreateParams myCp = base.CreateParams;
14
15 myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
16
17 return myCp;
18
19 }
20
21 }Or cancel the execution of the close event in the upper left corner
1 private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
2
3
4 {
5
6
7 e.Cancel = true;
8
9
10 }
11
12
13
14
15
16
17 // rewrite OnClosing Enables the form to indent the tray when the close button is clicked
18 //http://www.cnblogs.com/roucheng/
19
20 protected override void OnClosing(CancelEventArgs e)
21
22
23 {
24
25 this.ShowInTaskbar = false;
26
27 this.WindowState = FormWindowState.Minimized;
28
29
30 e.Cancel = true;
31
32
33 }Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/120707.html Link to the original text :https://javaforall.cn
边栏推荐
- Uploading and downloading of files
- Full automatic breast pump chip dltap703sd
- was not registered for synchronization because synchronization is not active[已解决]
- 多功能无线遥控艾灸仪芯片-DLTAP703SD
- 瑞吉外卖笔记
- 全自动吸奶器芯片-DLTAP703SD
- Runtimeerror: output with shape [1, 256, 256] doesn't match the broadcast shape [3, 256, 256] [error]
- 商品评论信息与评论信息分类
- [yuntu said] 249 mobile application security service - app's physical examination center, comprehensive testing, safe on the road!
- Jianmu continuous integration platform v2.5.2 release
猜你喜欢

Examples of map search

Nodejs 模板引擎ejs

What does the number of network request interface layers (2/3 layers) mean

TypeScript安装

Uni app traversal array rendering data vertical rendering

Canvas draws graphics according to coordinate points

全自动吸奶器芯片-DLTAP703SD

Ant privacy computing innovation tee technology has won academic recognition

订单的提交

Led with fan eye protection learning table lamp touch chip-dlt8s12a
随机推荐
Jianmu continuous integration platform v2.5.2 release
Typeerror: conv2d(): argument 'padding' (position 5) must be multiple of ints, not STR [error]
低噪负离子风扇触摸IC
Have you ever stumbled on MySQL's order by
JS tool - Cookie simple encapsulation
Full automatic breast pump chip dltap703sd
百度地图技术概述,及基本API与WebApi的应用开发
RuntimeError: output with shape [1, 256, 256] doesn‘t match the broadcast shape [3, 256, 256]【报错】
模仿线程扣除
Hash、Set、List、Zset、BitMap、Scan
Login page tablelayout
PyGame aircraft war game background implementation
Log4j epic loopholes, big companies like jd.com have been recruited
Music rhythm colorful gradient lamp chip -- dlt8s04a- Jericho
Interceptor拦截器
V-bind and V-for
Examples of map search
飞机大战碰撞检测
Canvas draws graphics according to coordinate points
商品推荐和分类商品推荐