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;

本人承接嵌入式软硬件项目开发,物联网项目开发。有意请加QQ295936912(注明来意)

原文地址:https://www.cnblogs.com/huanjun/p/7838152.html