Question : How do I get the string associated with each index of a listbox populated from a data object?

I have a Windows form written in VB.Net using VS2008.  
There is a multi-select listbox populated by a data object which is filled from a SQL table

I want to compare a value of each item in the listbox and select it if it matches a specific criteria.

Unfortunately, I get "System.Data.DataRowView" from lbWSIDNumber.Items(i).ToString

How do I access the value?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Me.Item_IdentificationTableAdapter.Fill(Me.Halmattrac.Item_Identification)
 lbWSIDNumber.SelectedItems.Clear()
Private Sub btn000_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn000.Click
        Dim i As Integer = 0
        MsgBox(lbWSIDNumber.Items.Count)  'shows 127 items
        For i = 0 To lbWSIDNumber.Items.Count - 1
            MsgBox(lbWSIDNumber.Items(i).ToString) 'shows System.Data.DataRowView
           If lbWSIDNumber.Items(i).ToString.ElementAt(3) = "0" Then
                lbWSIDNumber.SelectedIndices.Add(i)
            End If
        Next
    End Sub

Answer : How do I get the string associated with each index of a listbox populated from a data object?

anyway the code would look like this;

ctype(lbWSIDNumber.Items(i),DataRowView).item(index of your item).tostring
Random Solutions  
 
programming4us programming4us