Is there a way that I could access a label with variable parameters? For example, I have a list of labels (lbl00, lbl01, lbl02, lbl10, lbl11, lbl12) and need to be able to access them programmatically to change the background color. In the example below, strLabel = "lbl01", which would correspond to the correct object in my form, but this cannot be passed as a string. Is there any way I could make this work?
Thanks!
private void btnTest_Click(object sender, EventArgs e)
{
TestHilight("0", "1");
}
public void TestHilight(string x, string y)
{
String strLabel = "lbl" + x + y;
strLabel.BackColor = System.Drawing.Color.Green;
}
List<Label>orDictionary<string,Label>