Solved

missing dropbox.selekteditem.value  in vb2008

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

Expert Comment

by:MacroShadow
ID: 39776029
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
ID: 39776362
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 27

Accepted Solution

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

932 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

13 Experts available now in Live!

Get 1:1 Help Now