?
Solved

ComboBox Selectvalue return nothing.

Posted on 2009-04-01
5
Medium Priority
?
163 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

862 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