-1

In a Windows form, I can add controls into flowlayoutpanel dynamically by doing this:

for (int i = 0; i < 5; i++)
{
    Button button = new Button();
    butto.Name="btn_"+i.ToSting();
    butto.Text=i.ToSting();
    this.flowlayoutpanel1.Controls.Add(button);
}

It works very well, but when I set the variable 'i' to 1500, it seems like the flowlayoutpanel cannot display all its controls. Where is the error, and how can I solve?

What I want to do is create a user control which contains a flowlayoutpanel, and when I open a PDF document, I want to add an item which display thumbnails of each page into the flowlayoutpanel.

Pang
  • 9,564
  • 146
  • 81
  • 122
Homer
  • 1
  • 1
  • 1
  • are you add only button or more controls ? One WinForm control limit; 6000. becuse form handle table is 64k – VolkanCetinkaya Jun 30 '17 at 09:38
  • *"it seems like the flowlayoutpanel cannot display all its controls"* - how did you came to such conclusion? Are they not visible? Got a screenshot to show? Adding so many controls comes at cost, have you thought about using specialized controls to represent many items, e.g. [`ListView`](https://stackoverflow.com/q/456063/1997232)? – Sinatr Jun 30 '17 at 09:49
  • How many 20 pound pigs fit into a 100 pound poke? Not 1500. Set the panel's AutoScroll property to True to get ahead. – Hans Passant Jun 30 '17 at 10:20

1 Answers1

0

You can set flowlayoutpanel.AutoScroll = true in code or by design Property you can set AutoScroll by default true.

stephenmuss
  • 2,445
  • 2
  • 20
  • 29