问题
Consider I have a simple group box with two textboxes
When I expand the window I want to resize the my label and textbox. So I used the Anchor property, but it is getting overlapped. Textbox1 is overlapping with textbox2.
How can I maintain the size increase based on form size without overlapping
回答1:
You can achieve what you want like this:
- Add a TableLayoutPanel with 4 columns and place it inside your GroupBox.
- Place the Labels inside columns 1/3 and Textboxes inside columns 2/4
- Set
SizeType
of columns 1/3 toAutosize
and 2/4 to50%
- Set the
Anchor
-property of the TableLayoutPanel toTop, Left, Right
- Set the Textboxes and Labels
Dock
-property toFill
- Set the Labels
TextAlign
-property toMiddleLeft
来源:https://stackoverflow.com/questions/46316025/how-to-resize-controls-inside-groupbox-without-overlapping