1 Attachment(s)
ListBox.ListIndex = -1 doesn't clear current item highlight if app uses visual styles
I have a VB6 app with a form containing a ListBox control. The ListBox's Style property is set to 1, i.e. 'checkbox'. I add several items in the form's Load event and make them checked with a code like this:
Code:
List1.AddItem "Item 1"
List1.AddItem "Item 2"
List1.AddItem "Item 3"
List1.Selected(0) = True
List1.Selected(1) = True
List1.Selected(2) = True
List1.ListIndex = -1
The last statement must remove the blue selection from the last ListBox item. This thing has worked for years, but recently I discovered that it does not work if the app is styled using the OS visual styles. The assignment to the ListIndex property does nothing: the value of the ListIndex property remains the same (2 in the sample above) and the ListBox looks like this:
Attachment 182449
Pay attention to the fact that the blue selection in the ListBox is visible even when the control is not focused.
Is there a way to remove that blue selection from the ListBox with checkmarks when visual styles are used in a VB6 app?
Re: ListBox.ListIndex = -1 doesn't clear current item highlight if app uses visual st
Try:
Code:
List1.Selected(List1.ListIndex) = False
Re: ListBox.ListIndex = -1 doesn't clear current item highlight if app uses visual st
This also clears the checkmark:
Attachment 182452
But I need to remove the selection without unticking the item.