在不同分辨率的Windows窗体大小的问题

在不同分辨率的Windows窗体大小的问题

本文介绍了在不同分辨率的Windows窗体大小的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在窗口形式的发展新手,开发一些表格后,我已经注意到,形式不不同的分辨率显示正确,形式超越屏幕在某些分辨率

I am newbie in window forms development, after developing some forms i have noticed that forms are not displayed correctly in different resolutions, form go beyond the screen in some resolutions

我想知道是否有根据的分辨率可自动调整的形式,或者是有任何黑客或一些技术,我可以用它来设计窗体中的任何设置。

I was wondering if there is any setting which can auto adjust the form according to resolution, or is there any hack or some technique which i can use to design the form.

请详细说明你的答案有点就像我跟Windows窗体开发挺新鲜的。

Please elaborate your answer a bit as i am quite fresh with windows form development.

感谢

推荐答案

这里的问题更可能是它不工作,你期望的方式。在的WinForms开发,当你设计一个表格,你实际上是设置其大小。这遵循默认字体大小的正在显示上的形式,并且不直接关联到相关显示器上的分辨率在机器上的功能。所以,如果你设计一个大的形式有许多控件或大型控制,它可能在一个较高的分辨率,但不是在不足一个显示效果细腻。对于这个尺寸的更好的手感,看看你的Form1.Designer.cs文件,你会看到被设置为控件大小值。这些大小并不等同于像素,但是他们应该给你一个相对大小。你应该还研究的对话框单位的MSDN或其他地方。

The issue here is more likely that it is not working the way you expect. In WinForms development, when you design a form you are actually setting its size. This follows a function of default font size on the machine the form is being displayed on and does not directly correlate to the resolution on the display in question. So, if you design a large form with many controls or large controls, it may display fine at a high resolution but not at a low one. For a better feel of this sizing, take a look at your Form1.Designer.cs file and you will see size values being set for the controls. These sizes do not equate to pixels, but they should give you a relative sizing. You should probably also research dialog units on MSDN or elsewhere.

您可以编写一些代码来应对的形式加载事件该决议,但最终的尺寸将部分由你需要显示件的数量限制。如果你有一个多行编辑栏,网格控件,树控件或其他一些大型部件,可以自动调整它基于当前的显示分辨率,并在同一时间调整窗口大小。但是,这是根据您的需求的应用程序具体决定,这就是为什么Windows不尝试自动调整适合你。

You could write some code to react to that resolution in the form load event, but in the end the size will be partially constrained by the number of widgets that you need to display. If you had a multi-line edit field, grid control, tree control or some other large widget, you could automatically resize it based on the current display resolution and resize the window at the same time. But that is an application specific decision based on your needs, that is why windows does not try to automatically resize for you.

如上所述,WPF提供了更灵活的形式定义模型,可以比较活泼重新调整窗口小部件,但最终,如果你的表格是够忙的,一个WPF形式有一个较低的分辨率相同的问题。

As noted above, WPF gives a more flexible form definition model and can be more reactive to realign widgets, but in the end if your form is busy enough, a WPF form have the same issues on a lower resolution.

这篇关于在不同分辨率的Windows窗体大小的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:27