Link to home
Start Free TrialLog in
Avatar of Sheritlw
SheritlwFlag for United States of America

asked on

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

Avatar of JackOfPH
JackOfPH
Flag of Philippines image

Avatar of Sheritlw

ASKER

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
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

SOLUTION
Avatar of JackOfPH
JackOfPH
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

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