I've got a form with 20 TextBoxes(2-22)
and I would like to add them all the a List<TextBox>
So I can add the same text for example in all of them using the for-statement
.
What I thought(Lol.):
List<TextBox> textBoxes = new List<TextBox>();
for(int i = 2; i < 23; i++) {
//This String should refer to = textBox2, textBox3, etc
textBoxes.Add("textBox"+ Convert.ToString(i));
}
But this won't work because It can't convert a string to a textBoxName. You can do this:
textBoxes.Add(textBox2);
textBoxes.Add(textBox3);
textBoxes.Add(textBox4);
...So on
But ain't nobody got time for that... :)