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 不會顯示窗體標題欄等相關