Help resizing controls on form

lonewolf32

Newcomer
Joined
May 3, 2006
Messages
17
Can someone help me figure out how to set my anchors and dock settings on this form? I have tried several combinations but nothing produces the desired effect. I am using C# and Visual Studio 2005, with standard controls. The grids are DataGridViews.

What I want to see happen, is when the user resizes the form, the 2 grids always stay the same size as each other (growing OR shrinking, both vertically and horizontally), and the arrow buttons always stay between the two grids. I want the edges of the grids to stay on the form (not disappear off of the edge when shrunk) - this is easy with the vertical aspect using anchors, but the horizontal aspect is a real pain. At least, I haven't figured it out yet.

This would mean that the right grid's Location would be changing as the user resizes, and the buttons Location (they are on a Panel) would be changing, and both grids dimensions would be changing at the same time.

Nothing I have tried so far has produced the effect of keeping the grids the same size as each other. Plus, usually the right grid moves left and goes over the top of the buttons and over the top of the left grid. I even tried putting each in its own Panel, but so luck so far.

Any help is greatly appreciated.
Thanks!
 

Attachments

Take a look at the SplitContainer under Containers. Drag your DataGrids onto these and "Dock" them appropriately. Docking should ensure that resizing the window will have them adjust accordingly. Also consider that the zorder of controls can effect how they will be docked, so you can also right-click controls on your form and select "Bring To Front" to effect the positioning.
 
I tried this, and yes both datagridviews resize accordingly - but how do I get the arrow buttons in between them? I tried putting them in one of the split panes along with the data grid control, but the dgv just moves over my buttons when the app is resized (see attached).

Thanks!
 

Attachments

Back
Top