adding combobox item data

K

kmercer46

just asking on how to add item data in combobox??

in vb6;

combo1.additem "Item 1"
combo1.ItemData(combo1.NewIndex) = 1


but how about in .net??
 
C

Cor Ligthert [MVP]

Kmercer,

In .Net you have two posibilities. Use a datasource or use the itemarray.

With the itemarray which matches the most your question it is simple (watch
typos)

\\\
combo1.items.add("Item 1")
combo.selectedindex = -1
(in version 2002/2003 twice because of a bug).
///

I hope this helps,

Cor
 
G

Guest

Cor, what did you mean by the line:

(in version 2002/2003 twice because of a bug).

I haven't found any bugs yet in the combo box and I've used it a lot.
 
C

Cor Ligthert [MVP]

Dennis,
Cor, what did you mean by the line:

(in version 2002/2003 twice because of a bug).

I haven't found any bugs yet in the combo box and I've used it a lot.

Than you are probably one of the luckiest persons on earth, in my idea is it
the control with the most bugs.

One of those is that the combobox does not react if you set the index one
time to -1, a workaround written somewhere is to set it twice.

I agree that I don't see it as well anymore so maybe it is fixed in the sp1.

Cor
 
G

Guest

I have vb.net 2003 and framework 1.1 with sp1 and have several apps where I
set comboboxes to -1 routinely and haven't had any problems so it must have
been fixed. I typically use

combobox.Selectedindex = combobox.findstringexact and when it doesn't find
the string, it sets the combobox to -1.
 

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

Top