C#: The Winform control adapts to the form as the form size changes

Foreword:

When the window is maximized, the size of the space in the window will not change accordingly, and the user experience will be greatly reduced.

Solution:

Find the attribute of the control in the form: Anchor

Anchor defines the position of the anchor point of the control. If the size of the form is changed, the position between the control and the anchor point remains unchanged.

Anchor attributes can be selected:

Top-Indicates that the top of the control related to the parent form (or parent control) should remain fixed.

Bottom-indicates that the bottom edge of the control related to the parent form (or parent control) should remain fixed.

Left-Indicates that the left edge of the control related to the parent form (or parent control) should remain fixed.

Right-Indicates that the right edge of the control related to the parent form (or parent control) should remain fixed.

As a result, each control automatically maintains its position in the parent form.

Guess you like

Origin blog.csdn.net/weixin_44690047/article/details/112686091