2

我在 VS2012 的屏幕右上角附近将开始位置设置为手动。我试图稍后通过单击将这个窗口设置在中心,但无论我做什么,它都不会在中心..我该怎么做?

4

2 回答 2

3

只需将此代码添加到您的按钮单击事件中,

this.Location = new Point((SystemInformation.PrimaryMonitorSize.Width - this.Width) / 2, (SystemInformation.PrimaryMonitorSize.Height - this.Height) / 2);
于 2013-09-29T09:33:59.793 回答
1

使用Form.CenterToScreen方法

于 2013-09-29T06:49:23.780 回答