How to resize controls inside groupbox without ove

2019-06-08 16:45发布

Consider I have a simple group box with two textboxes

enter image description here

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.

enter image description here

How can I maintain the size increase based on form size without overlapping

1条回答
贪生不怕死
2楼-- · 2019-06-08 17:34

You can achieve what you want like this:

  1. Add a TableLayoutPanel with 4 columns and place it inside your GroupBox.
  2. Place the Labels inside columns 1/3 and Textboxes inside columns 2/4
  3. Set SizeType of columns 1/3 to Autosize and 2/4 to 50%
  4. Set the Anchor-property of the TableLayoutPanel to Top, Left, Right
  5. Set the Textboxes and Labels Dock-property to Fill
  6. Set the Labels TextAlign-property to MiddleLeft
查看更多
登录 后发表回答