PDA

Click to See Complete Forum and Search --> : How to highlight the last item in ListBox?


VBWG
Jan 27th, 2000, 06:56 AM
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.

Aaron Young
Jan 27th, 2000, 07:18 AM
Use the TopIndex Property of the Listbox, ie.
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
aarony@redwingsoftware.com
ajyoung@pressenter.com

VBWG
Jan 27th, 2000, 09:42 AM
Thank you Aaron for your help, I tried your tip and it works very well.
WG