Sunday, February 13, 2011

Visual Studio 2005 Windows MDI Form - Datagrid resize to fill screen

We had an MDI application that is basically a report with the report filter controls at the top of the form.  The problem we were having was that in certain instances based on the users monitor settings the datagrid wouldn't size correctly and it would end up cover some of the filter controls.

To work around this problem we did the following:

1. Add two panels to the form, the top panel houses the report filter controls and the bottom panel houses the datagrid.
2. We set the top panel Anchor to Top, Left.  The Dock property to Top
3. We set the bottom panel Anchor to Top, Left and the Dock property to Fill
4. For the datagrid the Anchor property got set to Top, Left and the Dock property to Fill.

This seems to have correct the problem.  The top filter portion of the screen stays static at the top and the bottom datagrid expands and contracts as you would expect it to to fill the rest of the form space.

No comments:

Post a Comment