VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > c#教程 >
  • C#教程之C#教程之C#实现窗体全屏

本站最新发布   C#从入门到精通
试听地址  
https://www.xin3721.com/eschool/CSharpxin3721/

方法一:设置窗体属性

复制代码
//程序启动路径,与生成程序的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 + "文件名");
复制代码

相关教程