?
Solved

Bound combo boxes display ID and not Description field

Posted on 2006-04-21
3
Medium Priority
?
216 Views
Last Modified: 2010-04-23
All combo boxes I have on the forms I'm designing display a record id instead of the description.  I am using a ScrollBar
with the CurrencyManager moving the position back and forth as one option for record selection.  As I scroll through the
table the values of my cmboPaymentTerms.Text changes to each of the record id's.  Needless to say the
cmboPaymentTerms.SelectedIndex remains at 0 because they are not being touched.  If I click on any of my combo
boxes they contain the appropriate list as specified by the DataSource.


        cmboPaymentTerms.DataBindings.Add("Text", dtContact, "payment_term_id")

        cmContact = CType(Me.BindingContext(dtContact), CurrencyManager)

        With cmboPaymentTerms
            .DisplayMember = "Description"
            .ValueMember = "payment_term_id"
            .DataSource = dtPaymentTerm
        End With

        cmContact.Position = 10       <-----  Hypothetically
        cmboPaymentTerms displays 0 instead of "Due on Receipt"


I have read about 10-12 forum posts trying to identify how to deal with this issue but cannot find anything that helps.

Trying to corollate the record id with a row will not work because my record id's are not sequential.

What is the value of .ValueMember?  It apparently has no bearing on displaying the proper .DisplayMember.
Would it not make sense to add a combo box property like .Binding where the field specified in .Binding would
synchronize the combo box with the .DataBinding and display the appropriate .DisplayMember?

Please help.  Thanks!

Phil Tate
0
Comment
Question by:TSFLLC
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Sancler
ID: 16509297
I suggest you try getting rid of this line

        cmboPaymentTerms.DataBindings.Add("Text", dtContact, "payment_term_id")

Roger
0
 
LVL 34

Accepted Solution

by:
Sancler earned 1000 total points
ID: 16509327
And, having now re-read your post, substitute this instead

        cmboPaymentTerms.DataBindings.Add("SelectedValue", dtContact, "payment_term_id")

Roger
0
 

Author Comment

by:TSFLLC
ID: 16509788
Roger,

I'm relatively new to VB.Net.  I've used Access & VBA for years but apparently need to
review databinding properties a little deeper.  This is exactly what I assumed should be
available.....a 'one-liner' to display the appropriate value.

Thanks!

Phil
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

850 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