Re: Listbox scroll problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

.



Relevant Pages

  • Re: Scroll bar
    ... You could add a Data Validation to cell B1 which would show a list of ... values, but until you had selected the value, the entry in C1 would not ... C1) will change while I am moving the scroll bar. ...
    (microsoft.public.excel.misc)
  • Re: Listbox scroll problem
    ... As I make various entries in a program, ... the scroll bar to see the latest. ... entry progresses. ... ListBox, simply execute this code... ...
    (microsoft.public.vb.general.discussion)
  • Re: Listbox scroll problem
    ... I have to operate the scroll bar to read the latest entry. ... entries disappear off the top (and can be brought back by scrolling if ... You'll need to precalc the number of visible rows, ...
    (microsoft.public.vb.general.discussion)
  • Scroll Through Pivot Table Entries
    ... I have a pivot table chart. ... The chart is setup to show only one entry ... I have with many different entries, 197 total, in the ... Is there a way to create a scroll bar from the Forms toolbar and use ...
    (microsoft.public.excel.misc)
  • Re: Listbox scroll problem
    ... progresses. ... I have to operate the scroll bar to read the latest entry. ... things so that the last entries are always showing, ...
    (microsoft.public.vb.general.discussion)