所以我在 Visual Studio C# 上制作游戏,我希望表单在编译时自动最大化到任何用户的计算机屏幕?我怎样才能做到这一点?
George Tyler
问问题
71186 次
7 回答
37
您可以使用以下方法之一来做到这一点——
- 设置窗体WindowState = FormWindowState.Maximized;
使用以下代码获取屏幕分辨率并相应地设置表单的大小
int height = Screen.PrimaryScreen.Bounds.Height; int width = Screen.PrimaryScreen.Bounds.Width;
于 2010-06-02T04:50:57.853 回答
22
将窗体的WindowState属性设置为Maximized
.
这将导致您的表单在打开时最大化。
于 2010-06-02T04:50:51.457 回答
13
You can use this.WindowState = FormWindowState.Maximized;
于 2013-01-06T09:59:03.600 回答
6
- 转到将表单加载为查看代码并使用此代码:
C#:
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
VB:
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
于 2015-12-03T10:25:25.290 回答
1
如果您正在寻找可以在第一次单击时最大化您的窗口并在第二次单击时标准化您的窗口的东西,这将有所帮助。
private void maximiseButton_Click(object sender, EventArgs e)
{
//normalises window
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
this.CenterToScreen();
}
//maximises window
else
{
this.WindowState = FormWindowState.Maximized;
this.CenterToScreen();
}
}
于 2017-05-31T12:18:17.077 回答
0
在 VS2010 中正确:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
于 2015-04-21T09:26:04.310 回答
0
在表单移动事件上添加:
private void Frm_Move (object sender, EventArgs e)
{
Top = 0; Left = 0;
Size = new System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
}
于 2019-05-16T19:26:47.737 回答