textbox content must match combobox selected row

30thjoint

New member
Joined
Apr 30, 2009
Messages
1
Programming Experience
Beginner
Hi!

I need to have a combobox that loads items from the first column of the database.

Now, as I select an entry on the combobox, a textbox beside it must display the data on the second column of the database.

As I change the combobox's selected item, the textbox's text must change accordingly.

I'm using SQL Server. Thanks!!!
 
Populate a DataTable with your data and then bind that to a BindingSource. You then bind the BindingSource to your two controls, e.g.:
VB.NET:
Me.BindingSource1.DataSource = myDataTable

Me.ComboBox1.DisplayMember = "LastName"
Me.ComboBox.ValueMember = "ID"
Me.ComboBox.DataSource = Me.BindingSource1

Me.TextBox1.DataBindings.Add("Text", Me.BindingSource1, "FirstName")
 

Latest posts

Back
Top