C#實現窗體全屏


方法一:設置窗體屬性

//程序啟動路徑,與生成程序的exe文件在同一目錄下
public String exePath = Application.StartupPath;
//定義窗體寬高
int screenWidth = 0;
int screenHeight = 0;
screenWidth = (int)System.Windows.SystemParameters.PrimaryScreenWidth;
screenHeight = (int)System.Windows.SystemParameters.PrimaryScreenHeight;
// 設置全屏   
this.FormBorderStyle = FormBorderStyle.None;     //設置窗體為無邊框樣式
this.WindowState = FormWindowState.Maximized;    //最大化窗體
this.Left = 0;
this.Top = 0;
this.Width = screenWidth;
this.Height = screenHeight;
//窗體背景圖
this.BackgroundImage = Image.FromFile(exePath + "文件名");

 

方案二:設置窗體尺寸

//程序啟動路徑,與生成程序的exe文件在同一目錄下
public
String exePath = Application.StartupPath; //窗口左上角位置 public Point m_formAutographShowPos; //設置窗體尺寸 this.Width = (int)System.Windows.SystemParameters.PrimaryScreenWidth; this.Height = (int)System.Windows.SystemParameters.PrimaryScreenHeight; this.ClientSize = new System.Drawing.Size(Width, Height); //計算初始位置 m_formAutographShowPos.X = 0; m_formAutographShowPos.Y = 0; Location = m_formAutographShowPos; //窗體背景圖 this.BackgroundImage = Image.FromFile(exePath + "文件名");


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM