You need to separate your concept of a datatable and the combo box, it
appears to be confusing you. You are correct in that you can add items to
the combo box, but unless you bind it you can't really use the valuemember.
When binding to a table you must have 2 columns, one for Display and another
for Value or if not the DisplayMember will take place of the ValueMember.
In your example, you're not really adding a default item, what you're really
doing is inserting an item at index 0, the very first item. If you only
have a Display member and want to populate the control manually then
reference those items, you can get the value this way:
ComboBox1.Items.Item(ItemNo) or the currently selected item: ComboBox1.Text
"c_shah" <sh*********@netzero.net> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
The ValueMember is only available to you when you bind
Does that mean I can only use value member property when i bind my
combobox to the dataset using data source? and I can't use value member
property when I iterate through the datarow collection in order to
populate combobox.
I am SQL DBA and started to learnVB.net so sorry about this newbie
questions...
in reference to your previous post
Thank you for elaborating this..actually I can add default item
(--select from combobox--) in the second approach easily by
combobox.items.insert(0,"--select from combobox--") but was not sure
how to get value property.