一、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;
