VB equivalent of Itemdata in Combo box

  • Thread starter Thread starter Sivaprasad
  • Start date Start date
S

Sivaprasad

Hi,

I have a combo box which displays FirstName+ Last Name of a person.
I want to store their id's in the combo like we store in ItemData of VB 6
combo box.
Is there any itemdata equivalent in VB.Net Combo?

Another problem is,
I am trying to do this using a class and add this class in the combo.
But SelectedIndexChanged event of combo box is returning the same last item
every time i change the selection.
Please help me on both.

Thanks
Siva
 
Yes,
after setting the datasource set the displaymember to the field you want to
see and the valuemember the the id.
Brad
 
'This is the code i have, to load the combo

****************************************

SQL = "Select distinct office from tblrace"

objRetrieve = objDatabase.RetrieveDataAccess(SQL)

While objRetrieve.Read

'My class has to items.One is office and the other is "Candidate name" both
are strings.In here I am adding only office

objclsCombo.Office = objRetrieve.Item("Office")

cboRace.Items.Add(objclsCombo)

End While

*****************************************

I put this code in this event, its always giving the last item in the combo.

but the combo shows the selected item.

Private Sub cboRace_SelectedValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboRace.SelectedValueChanged

MessageBox.Show(CType(cboRace.SelectedItem, clsComboRace).Office.ToString)

end sub

**************************************************************

Siva
 
Back
Top