Solved

missing dropbox.selekteditem.value  in vb2008

Posted on 2014-01-12
3
237 Views
Last Modified: 2014-01-13
entityview from dropboxi can't get the dropbox.value
0
Comment
Question by:ebertsys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

705 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