private void button1_Click(object sender, EventArgs e)
{
PictureBox dynamicPicture1 = new PictureBox();
dynamicPicture1.Tag = i;
dynamicPicture1.Location = new Point(x, y);
dynamicPicture1.Name = "pictureBox" + i;
dynamicPicture1.Size = new System.Drawing.Size(30, 27);
dynamicPicture1.ImageLocation =
"C:\\Users\\Newfolder\\Downloads\\x`enter code here`ryrvc.jpg";
panel1.Controls.Add(dynamicPicture1);
}
答案 0 :(得分:1)
您应该设置Method
的{{1}}名称:
event handler
并在某处定义事件处理程序:
dynamicPicture1.Click += dynamicPicture1_Click; //note the name here
事件处理程序的名称必须相互匹配...
答案 1 :(得分:1)
尝试此更新代码。
void dynamicPicture1_Click(object sender, EventArgs e) {
throw new NotImplementedException(); //default not implemented
}