Results 1 to 3 of 3

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

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2014
    Posts
    94

    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:

    Name:  2021-09-30_14h36_54.png
Views: 278
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?
    Last edited by wisekat; Sep 30th, 2021 at 06:40 AM.

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
  •  



Click Here to Expand Forum to Full Width