I have a list box that is bound to a datatable, which works fine. The question I have is this. I have a list of values in the form of a sqlDatareader that I want to use to select values in the list box, that is to say if the value from from the datareader matches the value member from the row in the listbox then select the row. I've come up with the following code, but can't find the syntax to utilize the SetSelected method. Could use some help please.
Thanks,
Tom
Private Sub SelectChargeConditions()
Dim rs As SqlDataReader
Dim i As Integer
Dim ConditionID
rs = clsDefendant.GetDefendantChargeConditions
Do While rs.Read()
For Each row As DataRowView In lbConditions.Items
ConditionID = row(lbConditions.ValueMember)
If rs("ID") = ConditionID Then
'Set the list box row to Selected here
End If
Next row
Loop
End Sub
Thanks,
Tom
Private Sub SelectChargeConditions()
Dim rs As SqlDataReader
Dim i As Integer
Dim ConditionID
rs = clsDefendant.GetDefendantChargeConditions
Do While rs.Read()
For Each row As DataRowView In lbConditions.Items
ConditionID = row(lbConditions.ValueMember)
If rs("ID") = ConditionID Then
'Set the list box row to Selected here
End If
Next row
Loop
End Sub