views:

27

answers:

2

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?

+4  A: 

Put a TableLayoutPanel in the left hand column with 3 rows and 1 column, dock each of the smaller controls in a row with docking stlye "fill", then anchor the TableLayoutPanel left, top, and bottom.

Paul Keister
I omitted this from my question for clarity, but there are two buttons between the top and center grids and two more between the center and bottom grids. I incorporated them into the table layout control with a split container, but unfortunately when I resize its the buttons that grow, not the DataGridViews. Any suggestions?
DonaldRay
Never mind, I found it. In the designer-generated code it adds RowStyles to the table layout control. I just had to change the button rows from Percent to Absolute and vice-versa for the grid rows.
DonaldRay
A: 

Try using the some SplitContainer controls in combination with some Panel or GroupBox containers. Then your user will have the ability to size as needed also.

eschneider