[英]Resize in Windows Forms controls along with form resize
我在C#Windows窗体应用程序中有一些控件(组框,表格,gridview等),我想根据屏幕宽度/高度来缩放它们。
例如,屏幕从640x480开始,然后最大化到1920x1200。
我希望能够增加控件的宽度/高度,以便在窗口重新调整大小后它们看起来完全相同。
如果不手动设置每个宽度/高度属性,最好的方法是什么?
如果不手动设置每个宽度/高度属性,最好的方法是什么?
您可以使用Anchor
和Dock
属性来控制根据其包含元素进行缩放,而不是指定宽度和高度。
或者,您可以使用TableLayoutPanel
或FlowLayoutPanel
来排列控件。
我相信你想要控件的Anchor
属性。
顾名思义,此属性强制控件将自身锚定在父窗体或控件内的相对位置或绝对位置。 此属性有四个值可以打开或关闭:
Top -- Indicates that the control should keep its top edge stationary in respect to the parent form (or control) top edge. Bottom -- Indicates that the control should keep its bottom edge stationary in respect to the parent form (or control) bottom edge. Left -- Indicates that the control should keep its left edge stationary in respect to the parent form (or control) left edge. Right -- Indicates that the control should keep its right edge stationary in respect to the parent form (or control) right edge.
IIRC,您想要使用Ctrl + A选择表单上的所有控件,然后将锚属性设置为顶部,底部,左侧和右侧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.