Results 1 to 3 of 3

Thread: How to highlight the last item in ListBox?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Fremont, CA, USA
    Posts
    2

    Post

    Is anyone could show me how to keep the recently added item in ListBox highlighted (selected) so that it is shown on screen?

    By simply using the AddNew method to add items to ListBox, the ListBox always shows the few items at top (starting from item0,1 and so on). After filling the total height of ListBox, the newly added item could not be seen on screen. Is any way to keep the ListBox Updated and shows the most recent items? Thanks in advance.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Use the TopIndex Property of the Listbox, ie.
    Code:
    Private Sub Command1_Click()
        Dim iIndex As Integer
        For iIndex = 0 To 10000
            List1.AddItem "Item " & iIndex
            List1.TopIndex = iIndex
        Next
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Fremont, CA, USA
    Posts
    2

    Post

    Thank you Aaron for your help, I tried your tip and it works very well.
    WG

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