窗体在当前显示窗口中居中,两个方法:
①设置StartPosition
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
②Winform的Paint事件
private void form1_Paint(object sender, PaintEventArgs e)
{
int gLeft = this.Width / 2 - form1.Width / 2;
int gTop = this.Height / 2 - form1.Height / 2;
form1.Location = new Point(gLeft, gTop);
}