Results 1 to 3 of 3

Thread: [RESOLVED] Remove listbox items (checkbox style)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Resolved [RESOLVED] Remove listbox items (checkbox style)

    Hi, normally I use the code below to remove selected (highlighted) listbox items.

    Now I have a listbox with the Style property set to 'Checkbox', but the code below doesn't work anymore. Instead of removing the selected/highlighted items it removes items with a ticked checkbox.

    How can I remove the selected/highlighted items and ignore the items with ticked checkbox? I searched the forums, but couldn't find an answer.

    vb Code:
    1. Private Sub cmdRemove_Click()
    2.     Dim i As Long
    3.  
    4.     With List1
    5.         For i = .ListCount - 1 To 0 Step -1
    6.             If .Selected(i) = True Then
    7.                 .RemoveItem i
    8.             End If
    9.         Next
    10.     End With
    11. End Sub

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Remove listbox items (checkbox style)

    Quote Originally Posted by Chris001
    Now I have a listbox with the Style property set to 'Checkbox', but the code below doesn't work anymore. Instead of removing the selected/highlighted items it removes items with a ticked checkbox...
    But that's what "Selected" means when listbox's Style = Checkbox.
    You can use ListView instead - I think each Item has Checked property so it's more flexible.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Remove listbox items (checkbox style)

    I was trying to avoid that, because the Listview (Common Controls 6.0) doesn't have XP style when I use a manifest file and all the other controls on the form do, so it looks a bit weird, but I guess I have no other options.

    Thanks.

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