【发布时间】:2015-03-13 18:13:31
【问题描述】:
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainScreen());
}
这是我创建和运行主屏幕的主屏幕,我尝试过使用:
- Form.StartPosition = CenterScreen/CenterParent
- 在构造函数中手动更改表单位置。
- 我什至尝试过单独创建表单,然后更改其 StartPosition,然后在 Application.Run() 中调用它。
这些都不起作用,它只是一直显示在屏幕的左上角。 关于如何使表格居中的任何想法?
【问题讨论】:
-
使用
Form.CenterToScreen方法 -
@AmeyaDeshpande CenterToScreen 方法 " 不打算直接从您的代码中使用。"
-
您确定没有将 StartPosition 设置为 Manual 的代码行吗?你的 Location 属性是 0,0?
-
@Steve 在查看表单属性后,我注意到 windowState 被设置为最大化,这可能是导致它的原因。现在已修复,感谢大家的回答。
-
我建议在您的发现中发布答案。虽然这是一个简单的错误,但它可能对未来的读者有用