我創建動態的一些圖片框和圖片框單擊事件如下獲取圖片框的數組的索引點擊
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