如何使Windows窗体适合任何屏幕分辨率或监视器? [英] How to fit Windows Form to any screen resolution or Monitor?

查看:112
本文介绍了如何使Windows窗体适合任何屏幕分辨率或监视器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#winform应用程序在VS 2013上工作。以下代码对我不起作用。我的表格设计为1024 x 768分辨率。



我们的客户笔记本电脑的分辨率为1366 x 768。为了解决这个问题,我在Form Load事件中设置了以下代码:



I work on VS 2013 with C# winform application. This below code does not work for me. My form was designed in 1024 x 768 resolution.

Our clients laptop is in 1366 x 768 resolution. To solve this problem, I set below code in Form Load event:

this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;





但是表单没有根据屏幕分辨率调整大小,我的表单底部被隐藏或剪切,或者我错过了滚动条。



有什么方法可以解决这个问题吗?请告诉我语法。在此先感谢



but the form does not resize as per screen resolution and bottom of my form gets hidden or cut or I miss the scroll bar.

Is there any way to solve this problem? Please show me the syntax. Thanks in advance

推荐答案

无法将 WindowState 属性设置为最大化



-KR
Can't you set the WindowState Property to Maximized ?

-KR


你所说的分辨率不是分辨率。这是显示器的大小(以像素为单位)。分辨率是可以分辨的每毫米/英寸的最大行数。要解决您的问题,请查看我过去的答案:

http://www.codeproject.com/Answers/150899/Zom-Out-malfunctions-when-Screen-resolution-change#answer1 [ ^ ],

http:// www .codeproject.com / Answers / 207268 / how-to-dock-button-so-can-can-adjust-with#answer1 [ ^ ](找到这里的基本代码示例),

http://www.codeproject.com /一个nswers / 587582 / CountingplusListViewplusitems-2cplusSelectedItemsp#answer3 [ ^ ]。



参见:

http://www.codeproject.com/Answers/151247/GUI-Apperance-C-Net#answer1 [ ^ ],

< a href =http://www.codeproject.com/Answers/835149/Cant-properly-redesign-GUI-to-get-better-user-expe#answer1> http://www.codeproject.com/Answers / 835149 / Cant-proper-redesign-GUI-to-getting-better-user-expe#answer1 [ ^ ]。



-SA
What you call "resolution" is not resolution. This is the size of the monitor in pixels. Resolution is the maximum number of lines per mm/inch which can be resolved. To address your problem, please see my past answers:
http://www.codeproject.com/Answers/150899/Zom-Out-malfunctions-when-Screen-resolution-change#answer1[^],
http://www.codeproject.com/Answers/207268/how-to-dock-button-so-that-it-can-adjust-with-the#answer1[^] (find a rudimentary code sample here),
http://www.codeproject.com/Answers/587582/CountingplusListViewplusitems-2cplusSelectedItemsp#answer3[^].

See also:
http://www.codeproject.com/Answers/151247/GUI-Apperance-C-Net#answer1[^],
http://www.codeproject.com/Answers/835149/Cant-properly-redesign-GUI-to-get-better-user-expe#answer1[^].

—SA


几年前PrimaryScreen.WorkingArea存在一个已知问题:[ ^ ]调用它的结果将被缓存,并且不会反映用户的任何UI更改,例如隐藏TaskBar。



修复方法是使用:SystemInformation.WorkingArea,它会在任何UI更改时重置。



我不确定此问题是否仍然存在,或者如果这与您正在做的事情相关,但您可以尝试使用SystemInformation。



几乎太明显无法询问清单:您是否对表格的最小值进行了硬编码/最大尺寸参数?或用'AutoSize?
There was a known issue with PrimaryScreen.WorkingArea a few years ago: [^] the result of invoking it would be cached, and would not reflect any UI change by the user, like hiding the TaskBar.

The fix was to use: SystemInformation.WorkingArea which is reset on any UI change.

I am not sure if this problem still exists, or if this is relevant to what you are doing, but you might try using SystemInformation.

Almost too obvious to ask checklist: have you hard-coded the Form's Minimum/Maximum Size parameters ? or done anything with 'AutoSize ?

这篇关于如何使Windows窗体适合任何屏幕分辨率或监视器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆