[英]How to make controls stretch and shrink when the window is resized?
调整窗口大小时,如何使所有控件都不在一个角上或只是耸耸肩,而是变得更大或更小以与窗口相对应?
You need to Anchor
your control(s) on the window. 您需要在窗口上
Anchor
控件。
Basically u (always) anchor your control on Top
& Left
(that's default anyway). 基本上,您(始终)将控件固定在“
Top
和“ Left
(无论如何都是默认设置)。
If you want to stretch your Control
horizontal add Right
. 如果要拉伸水平
Control
添加Right
。 For vertical stretching add Bottom
. 对于垂直拉伸,请添加
Bottom
。
[Properties] (rightclick the control you want to anchor and select properties) [属性] (右键单击要锚定的控件并选择属性)
Use Anchor property of each control to achieve the effect. 使用每个控件的Anchor属性可达到效果。
For example, if you set it to "Right, Bottom" on a control, it will keep its right and bottom side anchored (set to fixed distance) against the right and bottom edge of the form. 例如,如果在控件上将其设置为“ Right,Bottom”,它将使其右侧和底部固定在表单的右侧和底部边缘(设置为固定距离)。
This is sufficient for basic sizing. 这对于基本大小确定就足够了。 For advanced sizing, you have to size your controls manually on window resize event.
对于高级调整大小,您必须在窗口调整大小事件上手动调整控件的大小。
You might also want to set MinimumSize property of your form to prevent its window to shrink under that size. 您可能还需要设置表单的MinimumSize属性,以防止其窗口缩小到该大小以下。 This way you can prevent unwanted layout distortions like controls clipped or completely hidden behind right or bottom edge of the window.
这样,您可以防止不必要的布局失真,例如控件被裁剪或完全隐藏在窗口的右边缘或底边缘之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.