views:

68

answers:

1

I'm displaying a number of controls (all the same custom type) that can change their height in response to user input. The controls are being placed on a panel that's configured to automatically create a scrollbar if needed. The controls are arranged as a single column list.

What's the best way to reposition them when something changes in height? Can I set something in the designer to do this automatically, or will I have to manually move all controls below the one that's size changes manually?

+1  A: 

I suspect using a FlowLayoutPanel instead of a regular panel and refreshing after the child control changes height should do the trick.

Gareth S
That solved my vertical layout problem but is causing a new issue. All the controls in it aren't resizing themselves horizontally when the dialog width changes any longer despite being anchored left and right. The FlowLayoutPanel is resizing itself horizontally (scrollbar moves left to right).
Dan Neely
Experimenting more the problem is that the flow panel wants to be able to show the contained controls in multiple columns if it gets wide enough; I only even want a single column layout.
Dan Neely
I've been reading a bit on MSDN about how the FlowLayoutPanel works. The problem I'm having is by design. Instead of anchoring to the FLP itself, controls inside anchor (and dock) relative to the largest control contained in the FLP. I believe this means that I can make my layout work by adjusting the control widths on a resize; while this is easier than adjusting the vertical layout it's still not an ideal option.
Dan Neely
I guess you could derive a custom control from the FLP to gain finer control over the layout. Maybe setting FlowDirection = TopDown and WrapContents = False could solve your multiple columns issue though?
Gareth S
WrapContents = False can only solve part of it. It keeps a second column from forming when the FLP's width reaches 2xMyControlWidth; but it doesn't do anything to force MyControl to expand/contract in size when the FLP's width is changed.
Dan Neely