views:

982

answers:

0

I am currently programming my first Windows Forms application using C#. I'm using a TableLayoutPanel that will have a fixed 1X3 table [ 1 | 2 | 3 ], with each cell containing a flow panel that flows top to bottom. I have the row resizing option of the single row in the TableLayoutPanel set to autosize because I want the TableLayoutPanel to grow vertically as each flow panel grows vertically, which will happen when I add controls to the flow panel. The TableLayoutPanel is docked (DockStyle.Fill) in a UserControl which I also have autosizing and DockStyle.Fill in it's parent panel.

My problem is that when I add controls to flow panels, the flow panels grow correspondingly and the TableLayoutPanel's PreferredSize grows correspondingly but the actual size remains the same and does not grow. What am I missing that will trigger (or allow) the TableLayoutPanel to always size to it's PreferredSize?

Thank you!

EDIT:

I figured out that the issue was occuring because I had the described TableLayoutPanel docked in the top SplitPanel of a SplitContainer, which doesn't appear to resize when it's child is larger than its current size. I fixed my GUI by changing the SplitContainer to another TableLayoutPanel as I don't HAVE TO allow the panel to be user resized.

I would still be interested in finding out if it is possible to have a layout as I was attempting. The layout would look like the following xml structure:

<SplitContainer>
    <TopPanel>
        <TableLayoutPanel>
            <CellRow:0Col:0>
                <FlowPanelVertical>
                   ...Controls to be added here...
                </FlowPanelVertical>
            </Cell>
            <CellRow:0Col:1>
                <FlowPanelVertical>
                   ...Controls to be added here...
                </FlowPanelVertical>
            </Cell>
            <CellRow:0Col:2>
                <FlowPanelVertical>
                   ...Controls to be added here...
                </FlowPanelVertical>
            </Cell>
        </TableLayoutPanel>
    </TopPanel>

    <Splitter>

    <BottomPanel>
        <FlowPanelVertical>
            ...Controls to be added here...
        </FlowPanelVertical>
    </BottomPanel>
</SplitContainer>