Reputation: 607
I am trying to write a program that opens an arbitrary number of forms ( each one containing a label) when the user clicks on a button, and i put them on a list:
List<Form> formlist = new List<Form>();
...
public void showFrame()
{
Form f = new Form();
// I add the components i need ...
formlist.Add(f)
}
What i need now is, given the i index of the form in formlist, to change the label.Text of that form. Is possible to do it, withous using a different name for each lavel?
Upvotes: 0
Views: 753
Reputation: 941545
Give the control(s) you add to the form a Name. Then it is
formlist[i].Controls["somename"].Text = "mumble";
Upvotes: 4