当前位置:网站首页>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
边栏推荐
- js中的函数与DOM获取元素和事件属性的使用
- C file and folder input / output stream code
- 飞机大战敌机出场
- Interviewer: what do you think is your biggest weakness?
- The hero of the aircraft war comes out with bullets
- 微信支付及支付回调
- MySQL 01 关系型数据库设计
- Jianmu continuous integration platform v2.5.2 release
- Examples of map search
- Electric heating neck pillow chip-dltap703sc
猜你喜欢

MySQL 06 事务、视图、索引、备份和恢复

Music rhythm colorful gradient lamp chip -- dlt8s04a- Jericho

LeetCode 刷题 第一天

MySQL 02 初体验

Uniapp H5 cross domain problem

Quick access to website media resources

Electric heating neck pillow chip-dltap703sc

MySQL 03 高级查询(一)

Use ETL tools for data migration in salesforce project

商品推荐和分类商品推荐
随机推荐
Mode= "widthfix" attribute in image tag
Low noise anion fan touch IC
电动加热护颈枕芯片-DLTAP703SC
How to realize the full-text content retrieval of word, PDF and txt files?
Set the arc button to be displayed in the middle
Redis annotation
Bathroom with demister vanity mirror touch chip-dlt8t10s
filebeat.yml配置文件关于多个服务的配置问题
I was forced to optimize the API gateway query interface
Jianmu continuous integration platform v2.5.2 release
MySQL 03 高级查询(一)
Product name fuzzy search:
Use mobaxtermto establish a two-tier springboard connection
迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创
Uni app label jump
订单超时取消 及 按类别查询商品
MySQL 05 存储过程
ValueError: Found input variables with inconsistent numbers of samples: [80019456, 26673152]【报错】
RuntimeError: output with shape [1, 256, 256] doesn‘t match the broadcast shape [3, 256, 256]【报错】
JS to achieve smooth scrolling of pages or DOM elements