原文:http://www.cnblogs.com/freeliver54/archive/2008/11/22/1338877.html
0.新建窗体 及添加按钮
1.
执行如下按钮事件
private void btnFormMax_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.WindowState = FormWindowState.Maximized;
}
}
窗体最大化时 非全屏 不会遮盖任务栏
此时this.FormBorderStyle 默认为 Sizable
2.
执行如下按钮事件
private void btnFormMax_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
}
窗体最大化时 会全屏 及遮盖任务栏
此时this.FormBorderStyle 为 None 不会显示窗体标题栏等相关
3.
执行如下按钮事件
private void btnFormMax_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.FormBorderStyle = FormBorderStyle.None;
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
}
}
窗体最大化时 非全屏 不会遮盖任务栏
此时this.FormBorderStyle 为 None 不会显示窗体标题栏等相关