C#WinForms应用程序中组件的放置不一致。 [英] Inconsistent placement of components in C# WinForms app.

查看:68
本文介绍了C#WinForms应用程序中组件的放置不一致。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个WinForms应用程序,它使用表单继承为应用程序设置颜色和字体。 我不相信我的问题与继承有关,因为我在不使用表单继承的情况下复制了问题。

I have a WinForms application that uses form inheritance to set colors and fonts for the application.  I don't believe my problem has anything to do with inheritance because I've duplicated the problem without using form inheritance.

我注意到在几种形式上组件不显示在运行时和设计时相同的位置(即使在我的开发机器上)。 我可以在设计器中定位按钮,当我运行程序时,它们将显示错误定位
或完全不在表单上。 这与resize方法无关,因为某些受影响的表单没有定义这些方法。 虽然这种情况发生在我的开发机器上,但在其他具有不同屏幕分辨率的计算机上却更为严重。

I've noticed that on several forms the components don't display in the same positions at run-time as at design-time (even on my development machine).  I can position buttons in the designer and, when I run the program, they'll display incorrectly positioned or completely off the form.  This is not related to a resize method because some of the affected forms don't have these methods defined.  Although this happens on my development machine, it is more acute on other computers with differing screen resolutions.

我犯了什么罪恶? 为什么星星和行星对我不对?

What evil have I committed?  Why have the stars and planets aligned against me?

感谢您的任何见解...

Thanks for any insight...

推荐答案

检查控件的Anchor属性。默认值应为"左上角",这意味着控件的位置应相对于窗体的左上角保持不变。如果Anchor属性包括Bottom或Right,则当分辨率发生变化时,位置
和/或控件的大小可能会发生变化。
Check the Anchor property of the controls. The default should be Top-Left, which means that the position of the control should stay the same relative to the top-left corner of the form. If the Anchor property includes Bottom or Right, then the position and/or size of the control may change when the resolution changes.


这篇关于C#WinForms应用程序中组件的放置不一致。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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