Results 1 to 6 of 6

Thread: Listbox highlighting??????

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    8

    Unhappy

    If I have a multiselectable listbox...

    How do you programmatically/runtime, highlight an
    item in a listbox??? (could be more than one thats why I allowed multiselect)

    Cheers


  2. #2
    Guest
    Code:
    List1.Selected(2) = True
    List1.Selected(5) = True
    List1.Selected(8) = True

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    8
    Doesnt that force a List_Click call????

    I dont want that....

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Why don't you want that? got code in the List1_Click event?

    Then just use a boolean to tell the Event it's passed by code!

    Code:
    Private ByCode As Boolean
    
    Private Sub HighLight()
    'Tell it it's called by code
    ByCode = True
    'Highlight the items
       List1.Selected(2) = True
       List1.Selected(5) = True
       List1.Selected(8) = True
    'End telling it's by code
    ByCode = False
    End Sub
    
    Private Sub List1_Click()
    'If it's called by code don't do anything!
    If Bycode = True Then Exit Sub
    '... rest of your code here
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    8
    Yeah Ive got that but I was wondering if there was a better/neater way of doing it...

    Thanks anyway!

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Yeah there's probably is a complicated API way, but this works.

    Maybe http://www.mvps.org/vbnet/ has some API ways, but I don't know if it's worth the surfing
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

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