[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1036
  • Last Modified:

VB 2008 customer form. Update textbox field based on combobox selection

new to vb.net, creating a form where user can select customer from combobox and then the form will fill in the corresponding data for the textboxes on the form for the address fields.
The combobox is bound to a table with all the customers and their corresponding fields.
How do I populate the textboxes with the corresponding field data based on the selection of the combobox?
0
David Barman
Asked:
David Barman
1 Solution
 
theplonkCommented:
The are many ways to achieve this.

One simple way is to use the combobox SelectedIndexChanged event.

After you have assigned a handler for the event either through the UI or via code:
        AddHandler ComboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged

Firstly set the combobox ValueMember property to a column that is the unique identifier of the customer. This will be used to filter your table through the use of a View, which will be created from your existing table.
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim view As New DataView(table)
        view.RowFilter = "ID = " + Me.ComboBox1.SelectedValue
        nameTextBox.Text = view(0)("Name").ToString()
    End Sub

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now