0

How can I get items in listview?
I know how to get the current item if selected but Im trying to put it in a loop where i need to get my three row items there.

I have 3 columns and I want to get there items and insert it in entry string.

This code is wrong

 Dim a As Integer = 0
    For a = 0 To ListView1.Items.Count
        columname.Text = ListView1.FocusedItem.Text(a)
        columntype.Text = ListView1.Items(a).SubItems(1).Text
        columnscale.Text = ListView1.SelectedItems(a).SubItems(2).Text

        entry = entry + columname.Text + " " + columntype.Text + "(" + columnscale.Text + ")" + vbNewLine + "" & _
           ""
    Next
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Reverend Jim
0

Try

For row As Integer = 0 To ListView1.Items.Count - 1
    For col As Integer = 0 To ListView1.Columns.Count - 1
        Debug.WriteLine(ListView1.Columns(col).Text & ": " & ListView1.Items(row).SubItems(col).Text)
    Next
    Debug.WriteLine("")
Next

Edited by Dani: Formatting fixed

0

Never mind. Got it..

 Dim a As Integer = 0
    For a = 0 To ListView1.Items.Count - 1
        columname.Text = ListView1.Items(a).Text
        columntype.Text = ListView1.Items(a).SubItems(1).Text

        columnscale.Text = ListView1.Items(a).SubItems(2).Text

        entrynow = entrynow + columname.Text + " " + columntype.Text + "(" + columnscale.Text + ")" + vbNewLine + "" & _
           ""
    Next
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.