当前位置:网站首页>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
边栏推荐
- 地图找房的实例
- Matplotlib (basic usage)
- Personal Center - order business process
- What does the number of network request interface layers (2/3 layers) mean
- SQL server stored procedures multi angle introduction suggestions collection
- MySQL create event execution task
- [yuntu said] 249 mobile application security service - app's physical examination center, comprehensive testing, safe on the road!
- MySQL 04 advanced query (II)
- C basic concepts list description suggestions collection
- The song of the virtual idol was originally generated in this way!
猜你喜欢

npm 基本使用

瑞吉外卖笔记

Intelligent insomnia therapeutic instrument product dlt8p68sa Jericho

地图找房的实例

I'm stupid. When completable future is used with openfegin, it even reports an error

LeetCode 刷题 第一天

Nacos display service registration address error

Redis annotation

Day 3 of leetcode question brushing

Uni app form submit button send request
随机推荐
npm、cnpm 淘宝镜像
I was forced to optimize the API gateway query interface
Bathroom with demister vanity mirror touch chip-dlt8t10s
MySQL 06 事务、视图、索引、备份和恢复
Runtimeerror: output with shape [1, 256, 256] doesn't match the broadcast shape [3, 256, 256] [error]
Redis annotation
JDBC-MySql 01 JDBC操作MySql(增删改查)
USB rechargeable hand warmer chip dltap602sc Jericho
Canvas draws graphics according to coordinate points
Electric heating neck pillow chip-dltap703sc
MySQL 04 高级查询(二)
飞机大战碰撞检测
Hash、Set、List、Zset、BitMap、Scan
Talking about JVM (frequent interview)
MySQL 03 高级查询(一)
Intelligent insomnia therapeutic instrument product dlt8p68sa Jericho
Have you ever stumbled on MySQL's order by
个人中心--订单业务流程
V-bind and V-for
JS to achieve smooth scrolling of pages or DOM elements