tags:

views:

34

answers:

1

I have a FlowLayoutPanel, and I am constantly adding controls to it. They all work, yeah, life is wonderful.

But when the container hits its boundaries, it just stays the same size. Now, I realize I can make it have scrollbars, but this is not what I desire. I want the FlowLayoutPanel to grow in size based on the controls added. Any ideas?

I have AutoSize mode set to true, by the way. This doesn't seem to do anything.

+1  A: 

I added a FlowLayoutPanel to a Form. I added a button with the following Click handler:

private void button1_Click(object sender, EventArgs e)
{
    this.flowLayoutPanel1.Controls.Add(new Button());
}

On the FLP, I set FlowDirection to TopDown and AutoSize to true. I also set the BorderStyle to FixedSingle to see what's happening.

Now when you run this and click the button, it'll add other buttons to the FLP. When you add too many, the form hides the overflowing-FLP.

I'm not sure if this is what you're after, but if you want the Form to increase in size as well, you set AutoSize to true on the Form too.

If this isn't what you're looking for, please provide more details.

TheCloudlessSky
I want the FLP to keep growing, instead of hiding new controls. I don't care about the form.
Stacey
@Stacey - Not setting `AutoSize` on the `Form` allows the FLP to keep growing. Try creating a new project to test what I wrote out; it works for me.
TheCloudlessSky