VB equivalent of Itemdata in Combo box

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
 
B

Brad Shook

Yes,
after setting the datasource set the displaymember to the field you want to
see and the valuemember the the id.
Brad
 
S

Sivaprasad

I am not setting a datasource. I am adding the data to the combo with the
code.
Siva
 
S

Sivaprasad

'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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top