Joo
Joo

Reputation: 73

FlowLayoutPanel FlowDirection issue

I'm trying to add x Buttons to a FlowLayoutPanel which is docked (DocType fill) in a Panel. I have set the FlowDirection to Topdown as I want something like:
this

However, the FlowLayoutPanel has a horizontal scrollbar, not a vertical one:
See here

I add the buttons like this:

flowLayoutPanel1.Controls.Add(new Button { Text = "Chat", Width = flowLayoutPanel1.Width - flowLayoutPanel1.Margin.Left - flowLayoutPanel1.Margin.Right});

I also tried:

flowLayoutPanel1.Controls.Add(new Button { Text = "Chat", Dock = DockStyle.Fill});

And also:

flowLayoutPanel1.Controls.Add(new Button { Text = "Chat", Anchor = AnchorStyles.Left | AnchorStyles.Right});

I tried this and also looked here. Both don't work for me.

Thanks for your help.

Upvotes: 1

Views: 612

Answers (1)

Joo
Joo

Reputation: 73

after some digging here I found it out. I had to set the FlowLayoutPanel.WrapContents Property to false.

Upvotes: 2

Related Questions