Results 1 to 6 of 6

Thread: Multi-item delete [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213

    Multi-item delete [RESOLVED]

    What is the best way to delete multiple items from a listview?
    Last edited by GSIV; Dec 17th, 2003 at 06:59 PM.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    to remove the selected items you can do something like this
    VB Code:
    1. Dim item As ListViewItem
    2.  
    3. For Each item In ListView1.Items
    4.     If (item.Selected) Then
    5.           ListView1.Items.Remove(item)
    6.     End If
    7. Next
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    I don't think that would work, because if you delete item 0 then the item 1 will became it 0 and so on, so the thing is : you must start deleting from the last item to the 1st one so this kind of error doesn't happen
    \m/\m/

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    actually it works just fine. Because it is only removing the selected items...so if you select all the items...it just removes all the items.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  5. #5
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Lookin carefully at the code i think it is working because it is a for...each statement.
    Try doing it with a for() loop and it will pomp out an error
    \m/\m/

  6. #6

    Thread Starter
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213
    Thanks guys... this works good.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width