界面随电脑分辨率真自动调整 C#做的一个程序界面,当分辨率为8000*600时,显示不完整,分辨率太大了时,又留出很多空白。有些文本当界面缩小时,也挤到一块去了。像这种情况应该是比较普遍的,应该怎么解决呢。我们用播放器看电影时,就可以自由缩放而不会影响到电视的画面,为什么程序就不可以。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Screen.PrimaryScreen.Size //屏幕大小 //检查当前计算机的显示情况,便于调节窗体 private void CheckUserScreenArea() { //检查屏幕分辨率 if (Screen.GetWorkingArea(this).Width < 1024 | Screen.GetWorkingArea(this).Height < 768) { //MessageBox.Show("您的显示器分辨率过低或者可用的桌面区域过小,本程序可能无法显示完全。\r\n推荐调整至1024x768或更高分辨率,或调节Windows开始菜单栏的宽度以增加可用桌面显示区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height); this.MinimumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height); this.Width = Screen.GetWorkingArea(this).Width; this.Height = Screen.GetWorkingArea(this).Height; this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2; this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2; } else { this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height); this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight); this.Width = Screen.GetWorkingArea(this).Width; this.Height = Screen.GetWorkingArea(this).Height; this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2; this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2; } if ((Screen.GetWorkingArea(this).Width >= Program.NormalFormWidth) && (Screen.GetWorkingArea(this).Height >= Program.NormalFormHeight)) { this.MaximumSize = new Size(Program.MaxFormWidth, Program.MaxFormHeight); this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight); this.Width = 1024;//Program.NormalFormWidth; this.Height = 768;//Program.NormalFormHeight; this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2; this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2; } } 使用dock,设置Acchor属性判断分辨率 在不同分辨率下调整控件坐标窗体加载resize时改变坐标 给楼主的建议:1、用滚动条,界面显得不友好;2、建议控件设置dock的属性;3、如果控件太多,最好归类放在容器中; 让我看下你的using指令和引用。 谢谢 在C#代码中调用PGP加解密 过滤字符串 使其符合 文件命名规则 在c#中如何把一组图片装在数组中新手请教 C#异常处理问题 正则表达式 如何向一个长度为100的数组随机不重复插入一到一百 c# 如何获取Win2003中的已连接用户名称,怎样断开一个已连接用户? 急啊,图象编辑问题 C#如何把多个excel(每个excel包含两个个sheet)合并为一个excel; 如何用C#得到ACCESS中所用户表的表名!!!!!!!!!!!! Winform 中怎么判断两个集合中的元素是否有相同的啊?很急...求大侠指点指点 使用asp.net代码取消outlook会议
//检查当前计算机的显示情况,便于调节窗体
private void CheckUserScreenArea()
{
//检查屏幕分辨率
if (Screen.GetWorkingArea(this).Width < 1024 | Screen.GetWorkingArea(this).Height < 768)
{
//MessageBox.Show("您的显示器分辨率过低或者可用的桌面区域过小,本程序可能无法显示完全。\r\n推荐调整至1024x768或更高分辨率,或调节Windows开始菜单栏的宽度以增加可用桌面显示区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
this.MinimumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
this.Width = Screen.GetWorkingArea(this).Width;
this.Height = Screen.GetWorkingArea(this).Height;
this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2; }
else
{
this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight);
this.Width = Screen.GetWorkingArea(this).Width;
this.Height = Screen.GetWorkingArea(this).Height;
this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2; }
if ((Screen.GetWorkingArea(this).Width >= Program.NormalFormWidth) && (Screen.GetWorkingArea(this).Height >= Program.NormalFormHeight))
{
this.MaximumSize = new Size(Program.MaxFormWidth, Program.MaxFormHeight);
this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight);
this.Width = 1024;//Program.NormalFormWidth;
this.Height = 768;//Program.NormalFormHeight;
this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2;
}
}
判断分辨率
在不同分辨率下调整控件坐标
窗体加载resize时改变坐标
1、用滚动条,界面显得不友好;
2、建议控件设置dock的属性;
3、如果控件太多,最好归类放在容器中;