winform 弹出窗体位置设定
[转]https://www.cnblogs.com/liushenglin/p/5350641.html
一、C#中弹出窗口位置
加入命名空间using System.Drawing和using System.Windows.Forms
假定窗口名为form1,则
form1.StartPosition = FormStartPosition.CenterScreen;
窗体位置在屏幕中间
form1.StartPosition = FormStartPosition.CenterParent;
窗体在其父窗口中间
form1.StartPosition = FormStartPosition.Manual;
窗体在有其空间的Location属性而定
form1.StartPosition =FormStartPosition.WindowsDefaultBounds;
窗体位置由Windows默认位置决定,窗体大小也是Windows默认大小
form1.StartPosition =FormStartPosition.WindowsDefaultLocation
窗体位置在屏幕中间
form1.StartPosition = FormStartPosition.CenterParent;
窗体在其父窗口中间
form1.StartPosition = FormStartPosition.Manual;
窗体在有其空间的Location属性而定
form1.StartPosition =FormStartPosition.WindowsDefaultBounds;
窗体位置由Windows默认位置决定,窗体大小也是Windows默认大小
form1.StartPosition =FormStartPosition.WindowsDefaultLocation
窗体位置是Windows默认,大小在窗体大小中确定
二、获取屏幕
int width=SystemInformation.VirtualScreen.Width;
获取屏幕宽度
int height = SystemInformation.VirtualScreen.Height;
获取屏幕高度