Page 1 of 1

How to remove selected item

Posted: 09 Aug 2012, 23:44
by ufo973
there is nothing like explorerlistview.selecteditem.remove

so how can i remove/edit the selected item?

Re: How to remove selected item

Posted: 10 Aug 2012, 07:37
by TiKu
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

Re: How to remove selected item

Posted: 21 Nov 2012, 19:46
by engee30
And what if I have more than one item selected in a listview? How do I remove them all at once?

Re: How to remove selected item

Posted: 21 Nov 2012, 20:40
by TiKu
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.

Re: How to remove selected item

Posted: 21 Nov 2012, 22:08
by engee30
Yep, that does work - I've just had a go at it! Many thanks again.
:)