Combobox Not Showing Displaymember
I'm trying to display the Question ID's in the combo box, in order to reproduce the matching question in a text box. However rather than the Question ID's appearing, I am receiving
Solution 1:
You didn't post your Question class, but the DisplayMember and ValueMember fields aren't matching the property fields in the Question class:
It should look something like this:
PublicClass Question
Property QuestionID AsIntegerProperty QuestionText AsStringPublicSubNew(q_ID AsInteger, q_Text AsString)
QuestionID = q_ID
QuestionText = q_Text
EndSubEndClassThen your data source properties would look like this:
cmbQuestion.DisplayMember = "QuestionID"cmbQuestion.ValueMember = "QuestionID"cmbQuestion.DataSource = retrieveQuestions()
Solution 2:
You must first assign the datasource and then assign the field to show
cmbQuestion.DataSource = Nothing 'Resets data source
cmbQuestion.DataSource = retrieveQuestions() 'when form loads
cmbQuestion.DisplayMember = "Question_ID"
cmbQuestion.ValueMember = "Question_ID"
Post a Comment for "Combobox Not Showing Displaymember"