AlexF11
AlexF11

Reputation: 243

How can I make all panels resize equally when form is maximized

Currently when I maximize my form it resizes as it looks below.

enter image description here

This is due to the anchoring element stretching the two bottom panels on the left as well as causing a gap on the right since nothing is anchored right. I could fill the gap on the right by anchoring the right most panel however that would just cause it to be wider than all the other panels.

What I want is an equal resizing of the panels when the form is maximized as depicted below

enter image description here

How can this be achieved?

Upvotes: 0

Views: 1145

Answers (1)

Fabio
Fabio

Reputation: 32453

Use TableLayoutPanel:
Add TableLayoutPanel to the form and set Dock = Fill
Add 2 rows to the TableLayoutPanel (by default there is already two)

  • Row 1 - Height = 50%
  • Row 2 - Height = 50%

Add 4 columns to the TableLayoutPanel (by default there is already two)

  • Column 1 - Width = 25%
  • Column 2 - Width = 25%
  • Column 3 - Width = 25%
  • Column 4 - Width = 25%

Four panels on the left side put inside every cell of first and second columns and set Dock = Fill

Two panels on the left side put in the third and forth columns of the first row, set RowSpan = 2 and Dock = Fill

Upvotes: 1

Related Questions