Say I have 10 text boxes and I want to put the same text into each of them. I don\'t want to write textBoxNum. Text = \"hello!\" ten times so I might write somethin
textBoxNum. Text = \"hello!\"
Like this:
foreach (Control c in this.Controls) { if (c is TextBox) { ((TextBox)c).Text = "Hello"; } }
Assuming you want to set the text of all textboxes contained on the control\form, but can be modified for more specific scenarios