Results 1 to 4 of 4

Thread: Listview Remove Item

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    123

    Question Listview Remove Item

    Hi,

    I Have a listview with checkboxes,how can I remove the Items that have been checked from the listview?

    thanks
    Beware of the Dog

  2. #2
    Hyperactive Member
    Join Date
    May 2001
    Posts
    414
    Don't know if this is the best way but it's the only one I know

    Code:
    Dim i
    For i = ListView1.ListItems.Count To 1 Step (-1)
    If ListView1.ListItems(i).Selected = True Then
    ListView1.ListItems.Remove (i)
    End If
    Next i

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by jdc6029
    Don't know if this is the best way but it's the only one I know

    Code:
    Dim i
    For i = ListView1.ListItems.Count To 1 Step (-1)
    If ListView1.ListItems(i).Selected = True Then
    ListView1.ListItems.Remove (i)
    End If
    Next i
    Well
    I would dim i as an integer instead of variant
    and you would want to check the .Checked property.. not the selected property.. selected is if the listitem is currently highlighted

  4. #4
    Hyperactive Member
    Join Date
    May 2001
    Posts
    414
    I would dim i as an integer instead of variant
    and you would want to check the .Checked property.. not the selected property.. selected is if the listitem is currently highlighted
    You're right, I forgot to change Selected to Checked before I posted and thanks for the tip about As Integer

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