如何在每个图片框下添加进度条以及如何在进度条中显示每个下载文件进度

本文关键字:下载 文件 显示 添加 | 更新日期: 2023-09-27 18:37:05

在 Form1 中,我在左侧面板上创建 8 个图片框 4,在右侧面板上创建 4 个图片框。

pbs = new PictureBox[8];
            for (int i = 0; i < pbs.Length; i++)
            {
                pbs[i] = new PictureBox();
                pbs[i].MouseEnter += globalPbsMouseEnterEvent;
                pbs[i].MouseLeave += globalPbsMouseLeaveEvent;
                pbs[i].Tag = "PB" + i.ToString();
                pbs[i].Size = new Size(100, 100);
                pbs[i].Margin = new Padding(0, 0, 0, 60);
                pbs[i].Dock = DockStyle.Top;
                pbs[i].SizeMode = PictureBoxSizeMode.StretchImage;
                Panel p = i < 4 ? panel1 : panel2;
                p.Controls.Add(pbs[i]);
                pbs[i].BringToFront();
            }

如何在每个图片框下添加一个细进度条?

如何在每个图片框下添加进度条以及如何在进度条中显示每个下载文件进度

现在就做了。谢谢大家。

解决方案:

for (int i = 0; i < pbs.Length; i++)
            {
                progressbars[i] = new ProgressBar();
                progressbars[i].Size = new Size(100, 10);
                progressbars[i].Margin = new Padding(0, 0, 0, 70);
                progressbars[i].Dock = DockStyle.Top;
                pbs[i] = new PictureBox();
                pbs[i].MouseEnter += globalPbsMouseEnterEvent;
                pbs[i].MouseLeave += globalPbsMouseLeaveEvent;
                pbs[i].Tag = "PB" + i.ToString();
                pbs[i].Size = new Size(100, 100);
                pbs[i].Margin = new Padding(0, 0, 0, 60);
                pbs[i].Dock = DockStyle.Top;
                pbs[i].SizeMode = PictureBoxSizeMode.StretchImage;
                Panel p = i < 4 ? panel1 : panel2;
                p.Controls.Add(pbs[i]);
                p.Controls.Add(progressbars[i]);
                pbs[i].BringToFront();
                progressbars[i].BringToFront();
            }