Solved

Loop Through ListView Items/Columns

Posted on 2009-05-05
7
1,007 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now