Link to home
Start Free TrialLog in
Avatar of ebertsys
ebertsysFlag for Germany

asked on

missing dropbox.selekteditem.value in vb2008

User generated imagei can't get the dropbox.value
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

ComboBoxes don't have a SelectedItem.Value. The availible properties are; SelectedItem, SelectedValue and SelectedIndex.

I know it can be confusing with all the properties a combobox has to access the selected item in the control.

I highly recommend that you read this blog entry on this topic.

I will copy it here in case the link changes or gets removed.
ComboBox SelectedItem, SelectedValue, SelectedWhat???

ComboBox has a lot of helpful properties that allow you to get access to items selected by the Control.  The problem is knowing which one is best in which scenario.  The documentation is not 100% clear on what the values will be in various situations.  The most important factor to know is whether or not you are DataBinding in the ComboBox.

DataBinding Case

In this case the properties will have the following values

    SelectedItem - For gets this will return the actual object in the DataSource that is being displayed in the ComboBox.  For sets if the value exists in the DataSource, it will be selected, otherwise the operation will complete without an exception but won't actually do anything.
    SelectedValue - This property depends on the value of ValueMember.

    If the property ValueMember is not Nothing the ComboBox will look for a member on SelectedItem with the name specified in ValueMember and return that.  This is also the value displayed in the ComboBox.

    If the property ValueMember is Nothing, then the SelectedValue will return .ToString() on the SelectedItem
    SelectedIndex - Index of SelectedItem in the DataSource

Non-DataBinding Case

    SelectedItem - Gets and Sets both go to the currently selected object from the Items collection
    SelectedValue - Will be Nothing/null
    SelectedIndex - Index in the Items collection of the SelectedItem
Avatar of ebertsys

ASKER

Sorry for low details.
I want to have the id and the Text.
What i found in www is...bind the combox to a list.
So i put my sqlreader into a list and set the list as datasource
and set .valuemember=id
and set .textmember = text

and i want ..after.selctedindexchange the id of the selecte text.
ASKER CERTIFIED SOLUTION
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial