I'm looking for some advice on how to add click event handlers to labels that have been created created dynamically within a loop.
I've searched for click event handlers on dynamically created controls but this always comes back with single controls that aren't within an array.
example of code:
//create an array of 16 labels
Label[] label = new Label[16];
//loop through the array of labels
for (int i = 0; i < label.Length; i++)
{
label[i] = new Label(); //create new label
label[i].Name = "lbl" + i.ToString(); //give the label a name
label[i].Text = "label " + i.ToString(); //give the label text
}
Any help and advice on this would be great, thanks!