Solved

Loop Through ListView Items/Columns

Posted on 2009-05-05
7
993 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

13 Experts available now in Live!

Get 1:1 Help Now