mardi 18 octobre 2022

C# WinForms: 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.

Aucun commentaire:

Enregistrer un commentaire