简体   繁体   English

为什么-=运算符不像+ =那样调整Form大小?

[英]Why doesn't -= operator resize the Form size like += do?

I can resize automatically my form size at run-time using: 我可以使用以下命令在运行时自动调整表单大小:

Height += X

But

Height -= X

Has no side effect. 没有副作用。 It doesn't change anything in the form. 它不会更改表单中的任何内容。 Why that and how can I force the form to resize? 为什么会这样,我如何强制调整表单大小?

解决方案:

AutoSizeMode = GrowAndShrink;

It's possible that you are running into a minimum possible size issue - many controls allow you to access their size properties but do not allow changes or certain changes to come into effect. 您可能正遇到最小尺寸的问题-许多控件允许您访问其尺寸属性,但不允许更改或某些更改生效。 You can experiment with possible values in the designer and see which ones it rejects or alters. 您可以在设计器中试验可能的值,并查看拒绝或更改的值。

It may be that a property of your form is affecting this - for example the MinimumSize property. 可能是您表单的一个属性正在影响这种情况-例如MinimumSize属性。

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

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