Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Loop Through ListView Items/Columns

Posted on 2009-05-05
7
1,038 Views
Last Modified: 2012-06-27
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
Comment
Question by:Sheritlw
  • 4
  • 2
7 Comments
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24311508
0
 

Author Comment

by:Sheritlw
ID: 24311555
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
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24311571
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 15

Assisted Solution

by:JackOfPH
JackOfPH earned 100 total points
ID: 24311583
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
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 400 total points
ID: 24311589
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
 

Author Comment

by:Sheritlw
ID: 24311606
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
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24311625

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question