我有 50 张图片。我需要在 FlowLayoutPanel
中添加这些图像,换行后的第一行有 30 张图像,第二行有 20 张图像。所以我还需要在控件上显示滚动条。
我将视频分成帧(图像)并显示在 FlowLayoutPanel
中。当我上传第一个视频时,下面是设置图像的代码:
for (i = 1; i < len - 1; i++)
{
ImagePanel mybt = new ImagePanel(storagePath + words[0] + "_" +
i + ".jpg", words[0] + "_" + i + ".jpg");
flowLayoutPanel1.Controls.Add(mybt);
}
之后,当我上传第二张图片时,我想像第一行一样显示图片,我们在休息后有第一张视频图片,我需要显示第二张视频上传图片。 如果有人知道这怎么可能。
最佳答案
要获得您在屏幕截图中看到的结果:
- 将
FlowLayoutPanel
放入Panel
中,并将AutoScroll
属性设置为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。
关于c# - 多行自动调整大小的可滚动 FlowLayoutPanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32564463/