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:
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: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
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?




Reply With Quote
