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

Recommended Answers

All 3 Replies

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

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

Sorry about the formatting. Clearly we aren't in Kansas anymore.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.