views:

126

answers:

2

I have a groupbox that holds a flowlayout panel and the flowlayout panel holds a bunch of controls. I set the flowlayout panel to dock with the parent. Since I don't know how many controls will be in the panel, I set the group box autosize to true and autosizemode to grow and shrink. When I do this the groupbox shrinks as if it is empty. I need the caption so I can't remove the groupbox. Anyone know why this is happening?

A: 

You state "I don't know how many controls will be in the panel". Do you have any controls in the FlowLayoutPanel at design time? If you don't, this sounds like expected behavior. The Panel has nothing so its desired size is zero, so the GroupBox's desired size is zero.

If this is the case, then it should all hopefully size up when you actually add controls at runtime.

Willfulwizard
Yes I have controls in it at design time. Once i get everything working with a know number of controls. this code will be autogenerated based on an xml file. At which point I will not know how many controls there will be.
scott
+1  A: 

There's nothing that stops the FlowLayoutPanel from shrinking to nothing. You'll at least have to set its AutoSize property to True as well.

Hans Passant
thanks. that stopped the shrinking, but caused another problem. It grows horizonally causing the need to scroll side to side in the groupboxes parent container. previously scrolling was only vertical.
scott
You can set the MaximumSize.Width on the FLP to avoid that.
Hans Passant
thanks. that worked as well.
scott