怎么用代码设置窗体位置
怎么用代码设置窗体位置
开始的时候是一个小窗口,在屏幕的中央,点击“展开”后变成大窗口,怎么写代码才能是展开后的大窗口也在屏幕中央
this.Size = new Size(316, 180); this.Location = new Point(1000, 200);
int x = (Screen.PrimaryScreen.WorkingArea.Size.Width - this.Width) / 2;
int y = (Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height) / 2;
this.Location = new Point(x, y);