C# winforms 窗口尺寸是否可调整

设置窗口不可调整

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);

猜你喜欢

转载自blog.csdn.net/weixin_45792450/article/details/104185438
今日推荐