1

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.

Ken White
  • 123,280
  • 14
  • 225
  • 444
Joo
  • 41
  • 5
  • Have you tried to set the FLP's `FlowDirection = LeftToRight`? (TopDown = from Top until the Bottom is reached, then start over) – Jimi Oct 18 '22 at 22:33
  • A suggestion: set the FLP's `Padding` to `All = 0` and use the child Control's `Margin` to setup their layout inside the FLP. Assuming their Margin is set to `All = 3`, then the Width of the child Controls is `[FLP].Width - SystemInformation.VerticalScrollBarWidth - [Child].Padding.Left * 2 - 2` – Jimi Oct 18 '22 at 22:49

1 Answers1

2

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

Joo
  • 41
  • 5