Question : Combo box with Multiple Value Member in Vb.net Win Form

Hi Experts,
I have the below codes to populate a combo box and getting Value Member as Vend_cd after combo box selected index change. My problem is a want two values as a Value Member, as i know combo box have single display member and value member. I also know i can conconate two columns and can used as a display member or may be as value member too.

I want to get unit alongwith vend_cd after combobox selected index change event.
How can i do this. Please advise.



     Dim dataset As New DataSet
      Dim adapter As New SqlDataAdapter()
      adapter.SelectCommand = New SqlCommand("select distinct vend_item.vend_Cd,vend_item.Unit,vendor.vend_name from vend_item inner join vendor on vend_item.vend_cd=vendor.vend_Cd where vend_item.item_cd in (" + selectedVendor.ToString + ")", myconn)
  If myconn.State = ConnectionState.Closed Then myconn.Open()
  adapter.Fill(dataset)
   myconn.Close()
   CmbVendor.DataSource = dataset.Tables(0)
    CmbVendor.DisplayMember = "Vend_name"
     CmbVendor.ValueMember = "Vend_cd"

Bm Keshav

Answer : Combo box with Multiple Value Member in Vb.net Win Form

you can fetch ValueMember by selected value
for fetch other value you have to make your that DataSet available to whole form
i mean declare it as a global for that form

and in selectedindexchange you can find that field like atteched code

1:
2:
3:
4:
5:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If ComboBox1.SelectedIndex >= 0 Then
      MessageBox.Show(ds.Tables(0).Rows(ComboBox1.SelectedIndex).Item("EmpSal"))
    End If
  End Sub
Random Solutions  
 
programming4us programming4us