Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15537

ListBox.ListIndex = -1 doesn't clear current item highlight if app uses visual styles

$
0
0
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:

Name:  2021-09-30_14h36_54.png
Views: 24
Size:  1.6 KB

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?
Attached Images
 

Viewing all articles
Browse latest Browse all 15537

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>