[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:
Private Sub cmdRemove_Click()
Dim i As Long
With List1
For i = .ListCount - 1 To 0 Step -1
If .Selected(i) = True Then
.RemoveItem i
End If
Next
End With
End Sub
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.
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.