i have a textbox and combobox and a datatable (fill from database) datatable has two columns one is id and other is name the combobox is bind with this datatable like
Form1.ComboBox1.DataSource = dt
Form1.ComboBox1.DisplayMember = "name"
Form1.ComboBox1.ValueMember = "id"
if the user select a display member from comboBox1 dropdown the valuemember display in the textbox1 like
Private Sub ComboBox1_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
If ComboBox1.SelectedIndex = -1 Then
Return
Else
TextBox1.Text = ComboBox1.SelectedValue.ToString
End If
and the other process is if the user enter the value in textbox1 and in the leave hanler of textbox1 what we write that when an ID enter in the textbox1 and leave control its automatically selected the corresponding display member in ComboBox1. if not exist then clear the textbox1
Private Sub TextBox1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Leave
Dim dv As DataView
if ( dv = dv.RowFilter = "id =" & TextBox1.Text.ToString) then
//select the value memeber if record find
//ComboBox1.text = finded diaplay member
else
textbox1.text = string.empty
ComboBox1.selectindex = -1
end if
End Sub