How to remove selected item

The place for threads about TimoSoft ExplorerListView.
Post Reply
ufo973
Lieutenant
Posts: 12
Joined: 09 Aug 2012, 22:45

How to remove selected item

Post by ufo973 » 09 Aug 2012, 23:44

there is nothing like explorerlistview.selecteditem.remove

so how can i remove/edit the selected item?

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: How to remove selected item

Post by TiKu » 10 Aug 2012, 07:37

Remove:

Code: Select all

If Not ExplorerListView1.CaretItem Is Nothing Then
  ExplorerListView1.ListItems.Remove ExplorerListView1.CaretItem.Index
End If
Edit the label of an the caret item:

Code: Select all

If Not ExplorerListView1.CaretItem Is Nothing Then
  ExplorerListView1.ListItems.CaretItem.StartLabelEditing
End If
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

engee30
Lt. Commander
Posts: 54
Joined: 25 Sep 2012, 19:49
Location: Swindon, UK
Contact:

Re: How to remove selected item

Post by engee30 » 21 Nov 2012, 19:46

And what if I have more than one item selected in a listview? How do I remove them all at once?

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: How to remove selected item

Post by TiKu » 21 Nov 2012, 20:40

I'm not at home, so cannot test it, but this should work:

Code: Select all

  Dim col As ListViewItems

  Set col = ExLVwU.ListItems
  col.FilterType(FilteredPropertyConstants.fpSelected) = FilterTypeConstants.ftIncluding
  col.Filter(FilteredPropertyConstants.fpSelected) = Array(True)
  col.RemoveAll
Basically you take the collection of items and apply a filter to it that says "Include only those items that are selected". Then you remove all items in this collection.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

engee30
Lt. Commander
Posts: 54
Joined: 25 Sep 2012, 19:49
Location: Swindon, UK
Contact:

Re: How to remove selected item

Post by engee30 » 21 Nov 2012, 22:08

Yep, that does work - I've just had a go at it! Many thanks again.
:)

Post Reply