Getting ListView values into a string array?

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-04-20T08:29:34Z Indexed on 2010/04/20 8:33 UTC
Read the original article Hit count: 189

Filed under:
|
|
|
|

I have a ListView control set up in details mode, and on a button press I would like to retrieve all column values from that row in the ListView.

This is my code so far:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Dim items As ListView.SelectedListViewItemCollection = _
    Me.ManageList.SelectedItems
    Dim item As ListViewItem
    Dim values(0 To 4) As String
    Dim i As Integer = 0
    For Each item In items
        values(i) = item.SubItems(1).Text
        i = i + 1
    Next
End Sub

But values just comes out as an empty array. Any ideas? I just want the values array to be filled with the data of that ListView row.

Cheers.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about listview