当前位置: 移动技术网 > IT编程>开发语言>c# > C#实现窗体全屏的两种方法

C#实现窗体全屏的两种方法

2019年07月18日  | 移动技术网IT编程  | 我要评论
本文为大家分享了c#实现窗体全屏的具体代码,供大家参考,具体内容如下 方法一:不过此方法有时候会出现莫名的bug //程序启动路径,与生成程序的exe文件在

本文为大家分享了c#实现窗体全屏的具体代码,供大家参考,具体内容如下

方法一:不过此方法有时候会出现莫名的bug

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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网