ListView1 Item Hide

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

ListView1 Item Hide

Post by jstevens »

Is it possible to hide a ListView item using VBA?

As an example the ListView is loaded with 10 items. I have code that is run on each item and as the item is processed, it should be hidden. I didn't see an option to hide the item nor make the item's height = 0.

Increasing the ListView height does not make sense where the number of items could be 50 or more.

Your thoughts are appreciated.
Regards,
John

User avatar
HansV
Administrator
Posts: 78463
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: ListView1 Item Hide

Post by HansV »

That is not possible. You'd have to remove the item from the listview.
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: ListView1 Item Hide

Post by jstevens »

Thanks Hans.
Regards,
John

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: ListView1 Item Hide

Post by jstevens »

Here is a solution to removing the Items from a Listview. One needs to work from the bottom up to retain the Item.Index of each remaining item.

Code: Select all

Dim i As Long

For i = ListView1.ListItems.Count To 1 Step -1
    If ListView1.ListItems(i).Checked Then
        ListView1.ListItems.Remove i
    End If
Next i
Regards,
John