【问题标题】:Set window position in the center将窗口位置设置在中心
【发布时间】:2013-09-29 06:46:28
【问题描述】:

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

【问题讨论】:

  • 您已将位置设置为手动并单击按钮使其居中?
  • @AccessDenied 启动它的手册是的,点击我希望它居中..

标签: c# .net vb.net visual-studio-2012


【解决方案1】:

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

this.Location = new Point((SystemInformation.PrimaryMonitorSize.Width - this.Width) / 2, (SystemInformation.PrimaryMonitorSize.Height - this.Height) / 2);

【讨论】:

    【解决方案2】:

    使用Form.CenterToScreen方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多