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

x
?
Solved

Data bind a combobox and two text boxes

Posted on 2007-10-16
3
Medium Priority
?
197 Views
Last Modified: 2013-11-07
My form has a combobox which is tied to a dataset.   I would like to textboxes to change to values each time a new value is selected in the combobox.  How can I do this please?

thanks


  Dim countprogram
        DsPAmfgdrug1.Clear()
        Try
            countprogram = (SqlDataAdapter2.Fill(DsPAmfgdrug1))
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        cmbdrug.DataSource = DsPAmfgdrug1.Tables("tblPADrugFD")
        cmbdrug.DisplayMember = "Drug"
        cmbdrug.ValueMember = "GCN_SEQNO"
        Me.Label31.DataBindings.Clear()
        Me.Label31.DataBindings.Add("Text", DsPAmfgdrug1, "tblPADrugFD.AWP")
        Me.Label30.DataBindings.Clear()
        Me.Label30.DataBindings.Add("Text", DsPAmfgdrug1, "tblPADrugFD.Type")
0
Comment
Question by:running32
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
VBRocks earned 2000 total points
ID: 20088144
Try this:

 Dim countprogram
        DsPAmfgdrug1.Clear()
        Try
            countprogram = (SqlDataAdapter2.Fill(DsPAmfgdrug1))
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
        Dim dt as DataTable = DsPAmfgdrug1.Tables("tblPADrugFD")
        cmbdrug.DataSource = dt
        cmbdrug.DisplayMember = "Drug"
        cmbdrug.ValueMember = "GCN_SEQNO"
        Me.Label31.DataBindings.Clear()
        Me.Label31.DataBindings.Add("Text", dt, "AWP")
        Me.Label30.DataBindings.Clear()
        Me.Label30.DataBindings.Add("Text", dt, "Type")

0
 

Author Comment

by:running32
ID: 20095376
Thank you
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 20095900
You're welcome!  Glad I could help.

The reason why your code didn't work was because you created 2 different currency managers:
One for the datasource:   DsPAmfgdrug1.Tables("tblPADrugFD")
The other for the datasource:  DsPAmfgdrug1

Both of your labels that were bound to DsPAmfgdrug1 would have stayed in synch with each other,
but not with the combobox.  When we set all three datasources the same, then only one currency
manager was created, and all three controls stayed in synch.

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month19 days, 16 hours left to enroll

873 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