How can I execute a Sub with the value/text of every checked item inthe ListView?

I

iDesmet

Good day!

I was wondering if someone could show me the way with this little
problem I have.

I need to get the value/text of every checked SubItems in a listview
so I can execute a Sub.

The Sub I had created needs such value for inserting data in MySQL. My
Sub is called: InsertSelItem(ByVal SelItem As Integer)

I have a ListView (lvwItems) with Items that I get from a DB. In
lvwItems I have two columns. I get the value or text of a specific
item in a specific column using this:

Me.lvwItems.CheckedItems.Item(0).SubItems(1).Text

I also can get the number of checked items using this:

Me.lvwExpense.CheckedItems.Count.ToString

The question is: How can I execute a Sub with the value/text of every
checked item in the ListView?

Thanks in advance!

Regards,
iDesmet
 
J

James Hahn

This is one possibility:

For Each lvi as ListViewItem In lvwItems.CheckedItems
Dim ItemX as ListViewItem.ListViewSubItemCollection=
lvi.SubItems
InsertSelItem(ctype(ItemX.Item(1).Text, Integer))
Next
 
I

iDesmet

This is one possibility:

            For Each lvi as ListViewItem In lvwItems.CheckedItems
                Dim ItemX as ListViewItem.ListViewSubItemCollection=
lvi.SubItems
                InsertSelItem(ctype(ItemX.Item(1).Text, Integer))
            Next

Thanks a lot!

It worked like a charm!

Regards,
iDesmet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top