C# WinForm程序的全屏功能代码

2023-06-20,

  1. private void tsbFullWindow_Click(object sender, EventArgs e) 
  2.     if (tsbFullWindow.Text == "全屏"
  3.     { 
  4.         tsbFullWindow.Text = "取消全屏"
  5.         tsbFullWindow.Image = Properties.Resources.minimize; 
  6.         this.SetVisibleCore(false); 
  7.         this.FormBorderStyle = FormBorderStyle.None; 
  8.         this.WindowState = FormWindowState.Maximized; 
  9.         this.SetVisibleCore(true); 
  10.     } 
  11.     else 
  12.     { 
  13.         tsbFullWindow.Text = "全屏"
  14.         tsbFullWindow.Image = Properties.Resources.maximize; 
  15.         this.SetVisibleCore(false); 
  16.         this.FormBorderStyle = FormBorderStyle.Sizable; 
  17.         this.WindowState = FormWindowState.Maximized; 
  18.         this.SetVisibleCore(true); 
  19.     }