C# 实现窗体全屏后不遮挡及隐藏任务栏

做窗体项目时,有时根据实际需要全屏显示,对窗体的显示效果需求不同,以下实现如下:
//全屏后不遮挡任务栏

 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);
 }

猜你喜欢

转载自blog.csdn.net/qq_30725967/article/details/85322990