By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,681 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,681 IT Pros & Developers. It's quick & easy.

Combo Box

P: n/a
I'm confused as to how to use the combo box in vb.net. I want a combo box to
contain items that have both a display string and a value string. The display
string gets displayed in the drop down and the value string is the key of the
item
In vb6 i could add these items to the combobox and then use
combobox.selectedvalue to set or get the selected item. How do i do this in
vb.net?
It seems I can only enter one string?
Also how do I stop users typing into the combo box? i.e. force them to
select an existing value in the dropdown and not type one in.
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Kevin,

Your first question that means that you have to create an array or what I
prefer a datatable.

Than you can set as the datasource of the combobox and use both the
displaymember and the valuemember. The last gives when selected the
selectedvalue.

Your second question means that you have to set the combobox style to
dropdownlist.

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
thank you. I don't really understand how to go about using an array with the
combobox, but the datatable method seems promising.
for interests sake how would u implement using an array? a multidimensional
array? what would you set the displaymember and valuemember to? with a
datatable u would use the column name but how do u reference the dimesions of
the array?

kevin

"Cor Ligthert" wrote:
Kevin,

Your first question that means that you have to create an array or what I
prefer a datatable.

Than you can set as the datasource of the combobox and use both the
displaymember and the valuemember. The last gives when selected the
selectedvalue.

Your second question means that you have to set the combobox style to
dropdownlist.

I hope this helps,

Cor

Nov 21 '05 #3

P: n/a
Kevin,

You can add objects to an arraylist and use the properties of those.

I seldom did it, you have a lot to cast when you do it, I am lazy enough to
use the datatable.

Cor
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.