C#实现窗体全屏的两种方法
本文为大家分享了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 + "文件名");
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。
上一篇:C#如何使用SHBrowseForFolder导出中文文件夹详解
栏 目:C#教程
下一篇:C#中Datetimepicker出现问题的解决方法
本文标题:C#实现窗体全屏的两种方法
本文地址:https://www.xiuzhanwang.com/a1/C_jiaocheng/5026.html
您可能感兴趣的文章
- 01-10C#通过反射获取当前工程中所有窗体并打开的方法
- 01-10WinForm限制窗体不能移到屏幕外的方法
- 01-10C#实现txt定位指定行完整实例
- 01-10WinForm实现仿视频播放器左下角滚动新闻效果的方法
- 01-10C#实现清空回收站的方法
- 01-10C#实现读取注册表监控当前操作系统已安装软件变化的方法
- 01-10C#实现多线程下载文件的方法
- 01-10C#实现Winform中打开网页页面的方法
- 01-10C#实现远程关闭计算机或重启计算机的方法
- 01-10C#自定义签名章实现方法
阅读排行
本栏相关
- 01-10C#通过反射获取当前工程中所有窗体并
- 01-10关于ASP网页无法打开的解决方案
- 01-10WinForm限制窗体不能移到屏幕外的方法
- 01-10WinForm绘制圆角的方法
- 01-10C#实现txt定位指定行完整实例
- 01-10WinForm实现仿视频播放器左下角滚动新
- 01-10C#停止线程的方法
- 01-10C#实现清空回收站的方法
- 01-10C#通过重写Panel改变边框颜色与宽度的
- 01-10C#实现读取注册表监控当前操作系统已
随机阅读
- 01-10SublimeText编译C开发环境设置
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 04-02jquery与jsp,用jquery
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 01-10delphi制作wav文件的方法
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-11ajax实现页面的局部加载
- 01-10C#中split用法实例总结
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文