Solved

Binding Sources Navigation

Posted on 2008-06-19
6
195 Views
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.

Phill
0
Comment
Question by:PhillO
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:vbturbo
ID: 21832116
HI

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

Or

      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

         MessageBox.Show(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)
            MessageBox.Show(dr.ToString())
    End Sub

Hope this helps

vbturbo
0
 

Author Comment

by:PhillO
ID: 21832539
Thanks for the reply

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

Expert Comment

by:vbturbo
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

         MessageBox.Show(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    
0
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

 

Author Comment

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

Basically I'm trying to convert an ms access database to vb.net. 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.
0
 
LVL 18

Accepted Solution

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

https://filedb.experts-exchange.com/incoming/ee-stuff/7185-TestCBO.zip

vbturbo
0
 

Author Comment

by:PhillO
ID: 21835738
Absolutely Brilliant!! Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

16 Experts available now in Live!

Get 1:1 Help Now