C# 窗体启动位置设置:横向居中,纵向1/3
private void Form1_Load(object sender, EventArgs e) { int screenWidth = Screen.PrimaryScreen.WorkingArea.Width; int screenHeight = Screen.PrimaryScreen.WorkingArea.Height; int formWidth = this.Width; int formHeight = this.Height;
this.StartPosition = FormStartPosition.Manual;
this.DesktopLocation = new Point((screenWidth - formWidth) / 2, screenHeight / 3 - formHeight / 2);
}
原文地址: https://www.cveoy.top/t/topic/mRd2 著作权归作者所有。请勿转载和采集!