如何在每个pictureBox下添加进度条,如何在进度条中显示每个下载文件的进度?

时间:2013-10-27 16:25:52

标签: c# winforms

在Form1中,我在左侧面板上创建8个pictureBoxes 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();
            }

如何在每个pictureBox下添加一个瘦的progressBar?

1 个答案:

答案 0 :(得分:0)

现在就做了。 谢谢大家。

解决方案:

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();
            }