none
Listview - Remove multiple seleted items RRS feed

  • Question

  • Hi,

    I'm having some trouble to understand how I would remove multiple seleted items in a Listview.

    I know how to remove one by this code:

    Me.ListView1.ListItems.Remove(me.ListView1.SelectedItem.Index)

    I have tried to find a method on the net, but with no luck. 

    Wednesday, July 25, 2018 11:25 AM

Answers

  • Like this:

    Private Sub CommandButton1_Click()
        Dim i As Long
        With Me.ListView1.ListItems
            For i = .Count To 1 Step -1
                If .Item(i).Selected Then
                    .Remove i
                End If
            Next i
        End With
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Nikki Dee Wednesday, July 25, 2018 2:46 PM
    Wednesday, July 25, 2018 1:20 PM

All replies

  • Like this:

    Private Sub CommandButton1_Click()
        Dim i As Long
        With Me.ListView1.ListItems
            For i = .Count To 1 Step -1
                If .Item(i).Selected Then
                    .Remove i
                End If
            Next i
        End With
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Nikki Dee Wednesday, July 25, 2018 2:46 PM
    Wednesday, July 25, 2018 1:20 PM
  • Thank you very much, it works perfect :)
    Wednesday, July 25, 2018 2:47 PM