c# - Get class member by its name -
i need member of class within class.
in mainform (class design) have lot of combobox , textbox, write name 1 per 1 uncomfortable, think it's possible no sure.
for ilustrate, suppose have 10 combobox name 'cb_0..9' instead of write name of combobox want access selectedindex within loop:
for (int = 0; < 10; i++) { this.getmember("cb_" + i).selectedindex = 1; } is possible , simple ?
yes. need cast control able use combobox, e.g.
((combobox)this.controls["cb_" + i]).selectedindex = 1;
Comments
Post a Comment