fill three combo boxes

D

Doug

Hi

I have a list of about 50 text items (strings) that I would like to add to
about 5 combo boxes at various times depending on if a user clicks on the OK
button.

I have tried to code an example such as:
String ArrayList arr = new arr {"cat","dog","pig"};


this.cbo1.Items.Add(arr); but this doesn't work for me.

and i have tried:

string[] arr = {"cat","dog","pig"};


this.cbo1.Items.Add(arr);

but this puts "String[] Array" in the combo box.

I would like to create some way to call a method that will add the array to
any or all of the combo boxex.

For example if i click on button 'btnCbo1' the combo box cbo1 will have the
items in the choices, or btnCbo2 will make those choices available to cbo2
etc.



Any help appreciated.



Doug
 
D

Doug

hey i worked this out myself - dont know if it is the best way but this
work:

string[] arr = {"cat","dog","pig"};


this.cbo1.Items.AddRange(arr);
 
M

Moty Michaely

hey i worked this out myself - dont know if it is the best way but this
work:

string[] arr = {"cat","dog","pig"};

this.cbo1.Items.AddRange(arr);


I have a list of about 50 text items (strings) that I would like to add to
about 5 combo boxes at various times depending on if a user clicks on the
OK button.
I have tried to code an example such as:
String ArrayList arr = new arr {"cat","dog","pig"};
this.cbo1.Items.Add(arr); but this doesn't work for me.
and i have tried:
string[] arr = {"cat","dog","pig"};
this.cbo1.Items.Add(arr);

but this puts "String[] Array" in the combo box.
I would like to create some way to call a method that will add the array
to any or all of the combo boxex.
For example if i click on button 'btnCbo1' the combo box cbo1 will have
the items in the choices, or btnCbo2 will make those choices available to
cbo2 etc.
Any help appreciated.

Hi Doug,

It is the best way to add range of elements to a combo box.

Keep up the good work.

Moty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top