c# - How to refer to an object name through a variable? -


i have code open sqllite database, street names, , populate list box attached combo-box can suggest names user types them. want make procedure can call since used on may different combo-boxes. can pass name of control, how modify attributes of contol while referring variable?

something like:

string = "cbstreets" [a].text = "sets text combo box." 

if point me in right direction appreciate it.

instead of passing name of control, why not pass control (especially if they're comboboxes , same type?)

alternatively if reason can't pass control itself, set datastructure dictionary if need use string name:

dictionary<string, combobox> comboboxes = new dictionary<string, combobox>();  //use string want refer combobox , combobox item comboboxes.add("bcbstreets", combobox1);   //use name defined in previous step reference combobox , //set text comboboxes["bcbstreets"].text = "whatever"; 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -