Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1198
  • Last Modified:

Loop Through ListView Items/Columns

I am very new to .Net, and don't know how to loop through a listview and get it's values so that I can save in a database.
I fill the listview dynamically using...

With lst
                str(0) = CStr(iWatch1)
                str(1) = sTime
                itm = New ListViewItem(str)
                lst.Items.Add(itm)
            End With

Now I need to get the str(0) value and str(1) value to save

For i = 0 to lst.items.count - 1
How do I get the values for each column???
next

Thanks

0
Sheritlw
Asked:
Sheritlw
  • 4
  • 2
2 Solutions
 
JackOfPHCommented:
0
 
SheritlwAuthor Commented:
Unfortuntly when I click or transfer links my IE crashes.
I know I have a lot to learn about .Net.  I spent the last 15 + years programming with VB and before that with Cobol.
This app is for my sister and she needs it right away.  I figured I would develop it enough so she could use it and then rework it as I learn net.
I really just wanted an example of looping through a listview.
Thanks
0
 
JackOfPHCommented:
Try this...


For i = 0 to lst.items.count - 1
msgbox(lst.item(i).Subitems(0).value)
msgbox(lst.item(i).Subitems(1).value)
next

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
JackOfPHCommented:
oopss... change try this one
For i = 0 to lst.items.count - 1
msgbox(lst.item(i).Subitems(0).text)
msgbox(lst.item(i).Subitems(1).text)
next

Open in new window

0
 
Wayne Taylor (webtubbs)Commented:
Use something like the below example.

Wayne
For Each lvi As ListViewItem In ListView1.Items
    For c As Integer = 0 To lvi.SubItems.Count - 1
        MsgBox(lvi.SubItems(c).Text)
    Next
Next

Open in new window

0
 
SheritlwAuthor Commented:
Unfortunely item is not an option for the list.  Items is...
I filled it using a listviewitem
With lst

                str(0) = CStr(iWatch1)
                str(1) = sTime
                itm = New ListViewItem(str)
                lst.Items.Add(itm)

            End With

Trying to figure out how to get the information out.

Thanks
0
 
JackOfPHCommented:

For i = 0 to lst.items.count - 1
msgbox(lst.items(i).Subitems(0).text)
msgbox(lst.items(i).Subitems(1).text)
next
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now