Re: Listbox scroll problem
- From: "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Sat, 5 May 2007 15:39:02 -0400
I have a listbox which has items added to it progressively as user entry progresses. Whenever it is full, the scroll bar appears as expected. However, I have to operate the scroll bar to read the latest entry. How can I arrange things so that the last entries are always showing, ie the early entries disappear off the top (and can be brought back by scrolling if inspection is needed)?
Whenever you want to place the selection on the last item of the ListBox, simply execute this code...
List1.ListIndex = List1.ListCount - 1
Rick
Another way, if used right after adding an item, is to use the NewIndex property:
List1.AddItem "sample item"
List1.ListIndex = List1.NewIndex
While you are correct for the OP's implied usage (non-sorted ListBox), the real strength of the NewIndex property is for when you want to identify the latest entry added to a ListBox with its Sorted property set to True (you wouldn't know the ListIndex value for the item in this case).
Rick
.
- Follow-Ups:
- Re: Listbox scroll problem
- From: Gingre
- Re: Listbox scroll problem
- References:
- Listbox scroll problem
- From: Gingre
- Re: Listbox scroll problem
- From: Rick Rothstein \(MVP - VB\)
- Re: Listbox scroll problem
- From: Steve Gerrard
- Listbox scroll problem
- Prev by Date: Re: Listbox scroll problem
- Next by Date: Re: Listbox scroll problem
- Previous by thread: Re: Listbox scroll problem
- Next by thread: Re: Listbox scroll problem
- Index(es):
Relevant Pages
|