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!\"
You could also edit controls only matching something that you want. Here's an example.
foreach(Control ctrl in Controls) { if (ctrl.Name.StartsWith("TextBoxToEdit")) { ctrl.Text = "Hello!"; } }
Also, there is no need to cast the control into TextBox as Control already has the Text property.