WinForms: Making a set of controls scale vertically.
Posted
by DonaldRay
on Stack Overflow
See other posts from Stack Overflow
or by DonaldRay
Published on 2010-05-24T19:27:55Z
Indexed on
2010/05/24
19:31 UTC
Read the original article
Hit count: 410
I have a Windows Form that displays several DataGridViews in the following layout:
(No access to image hosting at work, so please pardon the ASCII art...)
+-----------------------------------------+
¦+-----------++--------------------------+¦
¦¦ ¦¦ ¦¦
¦+-----------+¦ ¦¦
|+-----------+¦ ¦¦
¦¦ ¦¦ ¦¦
¦+-----------+¦ ¦¦
|+-----------+¦ ¦¦
¦¦ ¦¦ ¦¦
¦+-----------++--------------------------+¦
+-----------------------------------------+
Unfortunately, when the user resizes the form to be taller, the form ends up looking like this:
+-----------------------------------------+
¦+-----------++--------------------------+¦
¦¦ ¦¦ ¦¦
¦+-----------+¦ ¦¦
| | ||
| | ||
|+-----------+¦ ¦¦
¦¦ ¦¦ ¦¦
¦+-----------+¦ ¦¦
| | ||
| | ||
|+-----------+¦ ¦¦
¦¦ ¦¦ ¦¦
¦+-----------++--------------------------+¦
+-----------------------------------------+
Instead of this:
+-----------------------------------------+
¦+-----------++--------------------------+¦
¦¦ ¦¦ ¦¦
¦¦ ¦¦ ¦¦
¦+-----------+¦ ¦¦
|+-----------+¦ ¦¦
¦¦ ¦¦ ¦¦
¦¦ ¦¦ ¦¦
¦+-----------+¦ ¦¦
|+-----------+¦ ¦¦
¦¦ ¦¦ ¦¦
¦¦ ¦¦ ¦¦
¦+-----------++--------------------------+¦
+-----------------------------------------+
To reproduce this, anchor the Top-Left DataGridView to Top-Left, the Center-Left DataGridView to Left, and the Bottom-Left DataGridView to Bottom-Left, and the big DataGridView to all 4.
What can I do to get the behavior I want?
© Stack Overflow or respective owner