Solved

missing dropbox.selekteditem.value  in vb2008

Posted on 2014-01-12
3
211 Views
Last Modified: 2014-01-13
entityview from dropboxi can't get the dropbox.value
0
Comment
Question by:ebertsys
  • 2
3 Comments
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
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
0
 

Author Comment

by:ebertsys
Comment Utility
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.
0
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
Comment Utility
That's what SelectedIndex is for.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now