简体   繁体   English

C#:自定义控件的大小自行调整

[英]C#: Custom control is resizing on its own

I have a custom control built of other controls that is being loaded in two different places. 我有一个由其他控件构建的自定义控件,该控件正在两个不同的地方加载。 On one it appears the way it does in the designer, as expected, on the other it is being resized smaller without being instructed to do so. 一方面,它看起来像在设计器中那样,正如预期的那样;另一方面,它正在缩小尺寸,而没有指示这样做。 Even when I explicitly adjust the size in code the control appears to get bigger, but the controls within are still smaller than they should be. 即使我在代码中显式调整了大小,控件似乎也会变大,但是其中的控件仍然比应该的小。 What could causing this to happen? 什么会导致这种情况发生?

Any differences in the font size between the custom controls' containers (form, panel, etc.)? 自定义控件的容器(窗体,面板等)之间的字体大小是否有差异?

See if setting your control's AutoScaleMode to Dpi helps. 查看将控件的AutoScaleMode设置为Dpi帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM