C# 设定弹出窗体位置

一、C#中弹出窗口位置

加入命名空间

using System.Drawing
using System.Windows.Forms

假定窗口名为form1,则

//窗体位置在屏幕中间
form1.StartPosition = FormStartPosition.CenterScreen;
//窗体在其父窗口中间
form1.StartPosition = FormStartPosition.CenterParent;
//窗体在有其空间的Location属性而定
form1.StartPosition = FormStartPosition.Manual;
//窗体位置由Windows默认位置决定,窗体大小也是Windows默认大小
form1.StartPosition =FormStartPosition.WindowsDefaultBounds;
//窗体位置是Windows默认,大小在窗体大小中确定
form1.StartPosition =FormStartPosition.WindowsDefaultLocation

二、获取屏幕

//获取屏幕宽度
int width=SystemInformation.VirtualScreen.Width;
//获取屏幕高度
int height = SystemInformation.VirtualScreen.Height;
posted @ 2017-11-15 11:48  随遇而安(huangjun)  阅读(5193)  评论(2编辑  收藏  举报