控件在不同计算机上的位置 [英] Position of controls on different computers

查看:93
本文介绍了控件在不同计算机上的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带有选项卡控件的表单.在其上方,有标签,组合框和文本框.
在开发机器上,它可以正常工作,但在分辨率不同的其他机器上,控件的位置会更改.组合框与选项卡控件重叠的某个位置,文本框和标签彼此不对齐的某个位置.
如何设置它,以便我的应用程序无论其分辨率如何都可以保持形状.
我尝试使用AutoScaleMode进行dpi,继承等操作,但没有任何效果.
感谢

Hi,
I have a form with a tab control. Above it, there are lables, combo boxes and text boxes.
On the development machine, it works fine but on other machines, where resolution is different, the position of the controls is changed. Somewhere combo box overlaps the tab control, somewhere text boxes and lables are not aligned with each other.
How to set it so that my application maintains the shape no matter what resolution it is.
I tried AutoScaleMode to dpi, inherit etc. but nothing worked.
Thanks

推荐答案

我唯一能想到的就是其他系统没有安装适当的字体,或者它们使文本大"了. "(在显示设置中)(而不是一次通过高级桌面设置并将字体一次设置到OS UI组件),这确实会影响您的布局.
The only thing I can think of is that the other system doesn''t have the appropriate font installed, or they''ve made their text "large" in their display settings (as opposed to going through the advanced desktop settings and setting fonts to OS UI components one at a time), which will really screw with your layout.


通常,如果您选择适当的缩放模式,并保持表格不太压缩并且没有(大)位图,这样结果就足够了...

您还必须使用一种相对标准的字体...就像在表单上默认使用的字体一样.我不确定,但是我认为大小是根据系统选择的字体完成的.

如果您使用的是第三方组件,则其中某些组件也可能无法正确自动缩放.因此,尽管标准控件是根据用户字体大小缩放的,但某些第三方组件却无法缩放(因此,相对于其余组件而言,它们太小了).

您还需要注意,某些控件(如日历控件)在XP和Vista之间的外观有所不同.如果这些控件周围有多余的空间,则将有助于避免不必要的重叠.

您可以轻松更改计算机的分辨率和字体大小以进行测试.

实际上,问题很少是分辨率,而是使用大字体或任何自定义字体大小.

我认为C#中的默认设置通常是合适的.但是,如果您有一个基于(大)图片的启动画面之类的表单,则必须强制该表单使用基于像素的大小.

否则,通常应基于系统字体大小来设置大小.

您还可以使用布局控件来帮助减少对实际大小的依赖程度.使用流或表布局可能会有所帮助.对于文本长度从一种语言到另一种语言都不同的多语言应用程序也是如此.

在极少数情况下,布局可能会在100%和125%的情况下正常工作,但在150%的情况下却无法正常工作.如果您尝试使用这3种字体大小,并且表格可以正确缩放,那么您可以确信,它将对大多数用户有效.

您还必须知道,字体缩放并不完全正确.如果您选择的字体大3倍,则某些字体中的小写字母l不会真正变宽.

最后是某些情况,如果实际面板尺寸大于允许的尺寸,您也可以使用具有自动滚动功能的面板.
Normally if you select the appropriate scaling mode and keep you form not too condensed and do not have (large) bitmaps it it, then the result is adequate...

You also have to uses a relatively standard font... like the one that is used by default on forms. I''m not sure but I think that sizing is done based on system selected font.

If you are using third-party components, some of them might not auto-scale correctly also. Thus while standard controls are scaled with user font-size, some third-party components do not scale (and thus are then too small relatively to the rest).

You also need to ba aware that some controls like the calendar control has a different look between XP and Vista. If you have some extra room around those controls, it will help to avoid undesired overlapping.

You can easily change resolution and font-size of your computer to make tests.

In practice, the problem is rarely the resolution but the uses of large font or any customized font size.

I think that default settings in C# are generally appropriate. But if you have a form like a splash screen that is based on a (large) picture, you will have to force the form to uses size based on pixed.

Otherwise, you should normally have size based on the system font size.

You could also uses layout control to help having a layout that is less dependant on the actual size. Using flow or table layout could help. The same would aply for multilingual applications where text length varies from one language to the other.

In some rare occasion layout might works properly at 100% and 125% but not at 150%. If you try these 3 font size, and the form properly scale, then you could be confident that it will works for most user.

You also have to be aware than scaling of font is not something exact. If you select a font size 3x bigger, a letter like a lowercase l won''t really be wider in some fonts.

Finally is some case, you might also uses panels with automatic scrolling if the actual panel size is larger than the allowed size.


请参阅我过去的回答中的建议:
屏幕分辨率改变时,Zom Out发生故障 [ ^ ].

另请参见有关常规UI设计的一些建议:
屏幕分辨率改变时,Zom Out发生故障 [ ^ ].

在这里,您将找到我的代码示例,其中包括与窗体对接(这是一种重要的分辨率公差设计技术):
如何停靠按钮,以便它可以使用以下格式进行调整 [
Please see my recommendations in my past answers:
Zom Out malfunctions when Screen resolution changes[^].

See also some recommendations on general UI design:
Zom Out malfunctions when Screen resolution changes[^].

Here you will find my code sample with Docking with Forms (which is an important design technique for resolution tolerance):
how to dock button so that it can adjust with the form[^].

—SA


这篇关于控件在不同计算机上的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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