我创建动态的一些图片框和图片框单击事件如下获取图片框的数组的索引点击
Image myImage = Image.FromFile("image/Untitled6.png");
PictureBox[] txtTeamNames = new PictureBox[5];
for (int i = 0; i < txtTeamNames.Length; i++)
{
var txt = new PictureBox();
txtTeamNames[i] = txt;
txtTeamNames[i].Image = myImage;
txtTeamNames[i].Height = 53;
txtTeamNames[i].Width = 48;
this.panel1.Controls.Add(txtTeamNames[i]);
txtTeamNames[i].Visible = true;
txtTeamNames[i].Click += new EventHandler(this.clcikeventhandle);
}
当用户点击任一图片框,我怎么找到它的数组索引和名称?
void clickEventHandler(object sender, EventArgs e)
{
//???
}
+1。现在只涉及范围。如果OP在课堂级声明'txtTeamNames',这就是答案。 – Neolisk