当前位置: 移动技术网 > IT编程>开发语言>.net > C#实现窗体全屏

C#实现窗体全屏

2018年10月26日  | 移动技术网IT编程  | 我要评论

方晓日,fmmix,2ggjj

方法一:适合wpf

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

 

方案二:适合winform

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网