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

  • Thread starter Thread starter iDesmet
  • Start date Start date
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
 
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
 
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
 
Back
Top