Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want that when i change the text in one combobox the text of other comboboxes should be change .some of comboboxes are populated from other tables and used in the same table as forgien keys. please help, i mean i have a form which have items and properties, price, weight etc, i want that when i change item name the properties, weight, price ect should also be chnage while the proeperties, weight, price are populated from database they are not stored as comboboxitems,
Posted

Imports System.Data.Odbc
Public Class Form1
Dim cn As New OdbcConnection("dsn=assam server")
Dim adp As OdbcDataAdapter
Private Sub cmbMaster_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbMaster.SelectedValueChanged
adp = New OdbcDataAdapter("select * from employeedet where employeeid='" & cmbMaster.SelectedValue.ToString() & "'", cn)
Dim ds As New DataSet
adp.Fill(ds)
cmbDetail.DataSource = ds.Tables(0)
cmbDetail.DisplayMember = "salary"
cmbDetail.ValueMember = "salary"
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
adp = New OdbcDataAdapter("select * from employee", cn)
Dim ds As New DataSet
adp.Fill(ds)
cmbMaster.DataSource = ds.Tables(0)
cmbMaster.DisplayMember = "employeename"
cmbMaster.ValueMember = "employeeid"
End Sub
End Class
 
Share this answer
 
on which combobox text u want to change the text of other,for that u have to write the code on seleted value changed .
there u have to bind data with other combo box.based on 1st combo box
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900