Issue Binding to ComboBox.
Dear Friends,
Please help me solve this problem(see source code on flollowing): When form load, in combo box will have 3 items with description what I would. But when I click Select button to show it's value then it will return: "ExamID" is the same with property that I assign for it while bind data.
For Example:
DisplayMember: Exam 1, Exam2 ,...OK
ValueMember: "ExamID" string. what I need: 1,2,...
I tried but I could not debug this problem.
Please help me....
Thank you very much
SOURCE CODE:
Private Sub BindData()
Dim conn As New OleDbConnection(DbObject.CONNECTION_STRING)
Dim cmd As New OleDbCommand("SELECT ExamID, Description FROM ExamEN", conn)
Dim adapter As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
adapter.Fill(ds, "Exam")
With listExam
.ValueMember = "ExamID"
.DisplayMember = "Description"
.DataSource = ds.Tables("Exam")
End With
adapter.Dispose()
End Sub
Private Sub SelectExam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Bind data to combobox
BindData()
End Sub
Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
Dim str As String
str = Me.listExam.ValueMember
MessageBox.Show(str)
End Sub
L.V.L
__________________
L.V.L
|