4

我的 C# Windows 窗体应用程序中有一些控件(组框、表格、网格视图等),我想根据屏幕宽度/高度来缩放它们。

例如,屏幕从 640x480 开始,然后最大化到 1920x1200。

我希望能够增加控件的宽度/高度,以便在重新调整窗口大小后它们看起来完全相同。

在不手动设置每个宽度/高度属性的情况下,最好的方法是什么?

4

2 回答 2

10

在不手动设置每个宽度/高度属性的情况下,最好的方法是什么?

除了指定宽度和高度,您可以使用AnchorDock属性使控件根据其包含的元素进行缩放。

或者,您可以使用TableLayoutPanelFlowLayoutPanel安排您的控件。

于 2013-05-06T17:01:24.750 回答
0

我相信你想要控件的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,然后将锚属性设置为顶部、底部、左侧和右侧。

于 2013-05-06T17:06:04.897 回答