Binding Sources Navigation

Posted on 2008-06-19
Last Modified: 2010-04-23
I have a binding source for an Address combobox in a project

The binding source has three columns suburbid, suburbname, postcodeid.  suburbid = value, suburbname = displaytext

I need to extract the postcodeid when a user selects a suburb. How do I do this.

Question by:PhillO
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
  • 3
  • 3
LVL 18

Expert Comment

ID: 21832116

        ComboBox1.ValueMember = "postcodeid"
        ComboBox1.DisplayMember = "suburbname"
        ComboBox1.DataSource = ds.Tables("Address")


      With Me.ComboBox1
            .ValueMember = "postcodeid"
            .DisplayMember = "suburbname"
            .DataSource = ds.Tables("Address")
            .DataBindings.Add("SelectedValue", ds.Tables("Address"), "postcodeid")
        End With

    Private Sub ComboBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged

        Dim i As Integer = ComboBox1.SelectedValue


         'Or you could get the specific row from the table you bound to the cbo
        If ComboBox1.SelectedIndex <> -1 Then
            Dim dr As DataRow = ds.Tables("Address").Rows(ComboBox1.SelectedIndex)
    End Sub

Hope this helps


Author Comment

ID: 21832539
Thanks for the reply

But how do I retrieve the actual postcodeid from the selected row
LVL 18

Expert Comment

ID: 21832724
this you do in the ComboBox1_SelectedValueChanged event

    Private Sub ComboBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged

        Dim i As Integer = ComboBox1.SelectedValue


the value(ComboBox1.SelectedValue) is the id value that you specified "ComboBox1.ValueMember = "postcodeid"!

That is the actual postcodeid from the selected  "suburbname"

suburbname          ID

Jane                       7    
Hans                      19                   MessageBox.Show(ComboBox1.SelectedValue) is = 19    
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.


Author Comment

ID: 21832901
Perhaps I'm going *way* down the wrong track. Please bear with me as I am new to

Basically I'm trying to convert an ms access database to In Access I can assign a combobox with three columns and just select the value of the third column. I don't know what the equivalent is here

The datasource for the combobox has three columns SuburbID, Suburb, & postcodeID, The combobox value is set to suburbID which is what I want but I am using the combobox to proccess two values. The SuburbID (which I know how to get) and the postcodeID ( what I don't know how to get).

At the moment I am finding the whole dataset/datatables/binding/mappings/etc a tad confusing.
LVL 18

Accepted Solution

vbturbo earned 500 total points
ID: 21833206
try check this upload ive made for you 


Author Comment

ID: 21835738
Absolutely Brilliant!! Thanks

Featured Post

Industry Leaders: 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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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