Reference multiple buttons on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to modify the Text property of 12 buttons on a form. They are already declared as button1, button2, ..., button12
With JavasCript this would be easy
for (int i=1; i<=12; i++)
eval("button"+i+".value") = <myText>; //The myText placeholder is a dataTable ro


How can it be done in C#

Thanks
Diego Rio
 
Controls don't have an exposed name property, so you can either loop through
the Controls collection looking for those with a Button type, you can have
an actual array declared that holds your buttons, or you can use reflection
to get them by name.

http://blog.opennetcf.org/ctacke/PermaLink.aspx/64c28b10-d3a8-4c6b-b11a-2ae2de4bdaf1

-Chris

Diego Rio said:
I need to modify the Text property of 12 buttons on a form. They are
already declared as button1, button2, ..., button12.
 
Back
Top