多行自动调整Scrollable FlowLayoutPanel

我有50张图片。 我需要在FlowLayoutPanel添加这些图像,在包裹行后第一行添加30个图像,在第二行添加20个图像。 所以我还需要在控件上显示滚动条。

我正在将video划分为帧(图像)并显示在FlowLayoutPanel 。 当我上传第一个video时,下面是设置图像的代码:

 for (i = 1; i < len - 1; i++) { ImagePanel mybt = new ImagePanel(storagePath + words[0] + "_" + i + ".jpg", words[0] + "_" + i + ".jpg"); flowLayoutPanel1.Controls.Add(mybt); } 

之后,当我上传第二张图片时,我想要显示像第一行中的图像,我们在rest后有第一个video图像,我需要显示第二个video上传图像。 如果有人知道它怎么可能。

要获得您在屏幕截图中看到的结果:

  • FlowLayoutPanel放在PanelAutoScroll属性设置为true
  • FlowLayoutPanel AutoSize属性设置为true
  • FlowLayoutPanel WrapContent属性设置为true (默认)
  • FlowLayoutPanel AutoScroll属性设置为false (默认)
  • 添加控件时,您可以使用SetFlowBreak来打破所需控件的控件流。

截图

在此处输入图像描述

 private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < 20; i++) { var btn = new Button() { Text = i.ToString() }; if (i == 5 || i==15 ) this.flowLayoutPanel1.SetFlowBreak(btn, true); this.flowLayoutPanel1.Controls.Add(btn); } } 

在这里,我打破了流量,在5和15。