做窗体项目时,有时根据实际需要全屏显示,对窗体的显示效果需求不同,以下实现如下:
//全屏后不遮挡任务栏
public User ()
{
this.StartPosition = FormStartPosition.Manual;//窗体初始位置
InitializeComponent();
this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;//工作区
this.WindowState = FormWindowState.Maximized;
}
//全屏后显示任务栏
private void Form1_Load(object sender, EventArgs e)
{
this.TopMost = true;
this.Location = new Point(0, 0);
this.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
}
//改变窗体边框样式,全屏后遮挡任务栏
private void Form1_Load(object sender, EventArgs e)
{
this.SetVisibleCore(false);
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.SetVisibleCore(true);
}