C# WinForm 关于窗体最大化时的是否全屏效果与是否遮盖任务
http://hi.baidu.com/tdskee/blog/item/cd7e63f0221977a7a40f52f4.html
新建窗体 及添加按钮
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 不会显示窗体标题栏等相关