C#设置窗体最大化 最小化 顶端显示

设置全屏:

this.FormBorderStyle = FormBorderStyle.None;

this.WindowState = FormWindowState.Maximized;

this.TopMost = true;      //这个一定要设置,不然一般会出现Bug

 

取消全屏,正常化:

 this.FormBorderStyle = FormBorderStyle.Sizable;

 this.WindowState = FormWindowState.Normal;

 

最小化:

 this.FormBorderStyle = FormBorderStyle.Sizable;

 this.WindowState = FormWindowState.Minimized;

 

获取屏幕尺寸:

int ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;  //显示器高度

int ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;    //显示器宽度

设置窗体居中最顶端显示 

this.SetBounds((System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - this.Width) / 2, 0, this.Width, this.Height);

 

如再要使得某个控件全屏,如GlobeContril、MapControl,只需要将他们的Top、Left、Width、Height等属性

设置为屏幕大小即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值