C# picturebox 动态添加

来源:百度知道 编辑:UC知道 时间:2024/05/29 07:45:05
请问一下,我想要实现picturebox动态添加。点击按钮就添加一个。一共要添加30次,请问用循环怎么写。每次添加的picturebox中的图片是不同的。

我试过很多方法,但是不会写循环。写三十次添加很费劲。
最好有具体点的代码。。。

看到你的问题了。。。具体在这儿
for (int i = 1; i < al.Count; i +=3)
{
// MessageBox.Show(al[i].ToString());
string id = al[i - 1].ToString();
PictureBox pic = new PictureBox();
this.toolTip1.SetToolTip(pic, al[i].ToString());
pic.Location = new System.Drawing.Point(0, 0 + i * 10);
pic.Size = new System.Drawing.Size(25, 25);
// MessageBox.Show(pic.Location.ToString());
string dz = @"..\kaixintp\" + id + ".gif";
pic.Image = Image.FromFile(dz); this.Controls.Add(pic);
// i += 3;
pic.Cursor = Cursors.Hand;
}

List<Image> images =new List<Image>();
images.Add("你的图片地址");//先全部加到这个变量中,另,这个可能用一个ImagesList控件实现也可

int i =0;
void btn_Click(object sender EventArgs e){<