views:

44

answers:

2

My C# project contains a form. There are some controls across the top of the form and some controls across the bottom of the form, as well as a FlowLayoutPanel in the center, all of which have been placed with the Visual Studio Form Designer.

During runtime, controls are dynamically added to and removed from the FlowLayoutPanel, and both the panel and the form itself are configured to automatically fit the size of they're contents.

However, since some controls were placed with the designer above and below the FlowLayoutPanel, the desired resizing fails to take place when new controls are added to the FlowLayoutPanel.

Does anybody know of a convenient remedy for this problem?

A: 

Your best bet might be to put all controls into a 'parent' TableLayoutPanel.

Jon
+2  A: 

Anchor the controls you want to move to the side(s) of the form they need to stay the same distance from.

BlueRaja - Danny Pflughoeft
Brilliant!!! But is there a way to have the form expand as the FlowLayoutPanel begins to intrude on the buttons below it, rather than after the panel has expanded through the buttons to the bottom of the form?
mcoolbeth
Uhh.. check the `FlowLayoutPanel.Bounds.Bottom` and compare it to the `Button.Bounds.Top`?
BlueRaja - Danny Pflughoeft