Solved

ComboBox Selectvalue return nothing.

Posted on 2009-04-01
5
148 Views
Last Modified: 2012-06-27
I am trying to read and set the value of an item in a combo box.
when flicking through the dataset the SelectedValue is always nothing

However the text returns the current value.

I want to set and retrieve the SelectedValue (StaffID), how can I do that ?



OnLoad init combo box:

       ' No problem there the list comes up perfectly

        With Me.ipCbCSO

            .DataSource = Me.bsStaffList

            .ValueMember = "staffID"

            .DisplayMember = "name"

        End With
 
 

....   ON databound positionchanged:

        ' Set Combo text value. (Since I cannot SET the ID value ??)

        Me.ipCbCSO.Text = txtCSOname.Text

         ' This works fine.

        Debug.Print("******** >>>>" & Me.ipCbCSO.Text)

          ' Returns nothing

        Debug.Print("******** ======>>>>" & ipCbCSO.SelectedValue)

Open in new window

0
Comment
Question by:siacom
5 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24047369
Is your StaffID a numeric value or a string ?
Did you check the selectedText, selectedIndex, selectedValue, ... ? (to make sure that something is selected)
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24049189
Try changing this line
Me.ipCbCSO.Text = txtCSOname.Text

to this
Me.ipCbCSO.SelectedIndex = ipCbCSO.FindStringExact(txtCSOname.Text)
0
 

Author Comment

by:siacom
ID: 24154107
Sorry for any late replies.. I was on holidays :)

staffid is integer.
I removed any values in selected index because it just doesn't give the appropriate result.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24155482
>I removed any values in selected index because it just doesn't give the appropriate result.
What do you mean? Did you try using the code?
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24166058

 Debug.Print("******** ======>>>>" & ipCbCSO.items.item(ipCbCSO.SelectedIndex).value)

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now