欢迎来到代码驿站!

.NET代码

当前位置:首页 > 软件编程 > .NET代码

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

时间:2021-09-07 09:10:39|栏目:.NET代码|点击:

本文为大家分享了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 + "文件名");

上一篇:ASP.NET MVC错误处理的对应解决方法

栏    目:.NET代码

下一篇:C#的泛型方法解析

本文标题:C#实现窗体全屏的两种方法

本文地址:http://www.codeinn.net/misctech/173237.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有