Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 VS2012 的屏幕右上角附近将开始位置设置为手动。我试图稍后通过单击将这个窗口设置在中心,但无论我做什么,它都不会在中心..我该怎么做?
只需将此代码添加到您的按钮单击事件中,
this.Location = new Point((SystemInformation.PrimaryMonitorSize.Width - this.Width) / 2, (SystemInformation.PrimaryMonitorSize.Height - this.Height) / 2);
使用Form.CenterToScreen方法