C# winforms 窗口尺寸是否可调整
程序员文章站
2022-06-08 17:43:13
...
设置窗口不可调整
this.FormBorderStyle = FormBorderStyle.FixedDialog;//设置边框为不可调节
this.MaximizeBox = false;//取消最大化按键
this.MinimizeBox = true;//可以最小化按键
设置窗口屏幕居中
//设置窗口居中
int height = System.Windows.Forms.SystemInformation.WorkingArea.Height;
int width = System.Windows.Forms.SystemInformation.WorkingArea.Width;
int formheight = this.Size.Height;
int formwidth = this.Size.Width;
int newformx = width / 2 - formwidth / 2;
int newformy = height / 2 - formheight / 2;
this.SetDesktopLocation(newformx, newformy);
上一篇: 我的第一篇博客