|
-
Sep 30th, 2021, 03:24 AM
#1
Thread Starter
Lively Member
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:

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?
Last edited by wisekat; Sep 30th, 2021 at 06:40 AM.
-
Sep 30th, 2021, 08:18 AM
#2
Addicted Member
Re: ListBox.ListIndex = -1 doesn't clear current item highlight if app uses visual st
Try:
Code:
List1.Selected(List1.ListIndex) = False
-
Sep 30th, 2021, 09:12 AM
#3
Thread Starter
Lively Member
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|