VB / C#: Resizing two controls equally

后端 未结 1 951
离开以前
离开以前 2021-01-18 12:31

I have made a window in which I will be having two groups/panels and some buttons in between them. I want to code the resizing behavior in a way that when the window expands

1条回答
  •  孤城傲影
    2021-01-18 13:11

    Use the TableLayoutPanel control.

    First add the TableLayout to the Form and set its Dock() property to Fill. Next you'll need to setup 3 columns and two rows. Add the two buttons to the middle column with each one is in its own row. Afterwards, setup the column values so they are like this: enter image description here Leave the rows at 50% on both. Now add your two GroupBoxes to the 1st and 3rd columns in the 1st row. For both GroupBoxes, set Dock() to Fill, and RowSpan() to 2. For the top Button, turn on only the Bottom Anchor. For the bottom Button, turn only the Top Anchor. For the TableLayoutPanel, set Padding() to 5,5,5,5.

    Here is what it looked like when I was all done: enter image description here

    Resize the window and observe how the controls behave...

    0 讨论(0)
提交回复
热议问题