Re: Listbox scroll problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



List1.AddItem Text1.Text
List1.TopIndex = List1.NewIndex

Is this what you want?



"Gingre" <not@xxxxxxxx> wrote in message news:463ce4b8@xxxxxxxxxxxxxxxxxxxx
I suspect this has missed the point, owing to my incompetence at
explaining
it... I'll try again.

As I make various entries in a program (in text boxes), I use the code...
List1.AddItem Text1.Text

As the entries proceed, the list box fills up. When it is full the scroll
bar appears, but I continue to see only the first entries, and have to use
the scroll bar to see the latest.

I want to have it the other way: I want the latest items to remain
visible,
while the earlier ones "fall out of" the list box and must be brought back
with the scroll bar.


"Rick Rothstein (MVP - VB)" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx> wrote in
message news:%23gzMP00jHHA.5048@xxxxxxxxxxxxxxxxxxxxxxx
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: 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: Add / Remove Programs is BLANK!
    ... I do not have negative entries either. ... "Chad Parks" wrote: ... There is not a scroll bar either so it's not just blank ... > I'm running Windows XP w/SP2 included on the CD. ...
    (microsoft.public.windowsxp.general)
  • Re: Some info boxes too small to read all info
    ... scroll bar. ... resize the entries in the title bar to see long entries. ... they not provide a normal re-sizeable window? ...
    (microsoft.public.windowsxp.general)
  • Re: Change size of scroll bar
    ... Debra Dalgleish has some techniques for trying to reset it: ... > After changing the entries on a spreadsheet, the scroll bar is miniscule for ... > the number of entries. ... > scroll bar on the side of the worksheet. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Listbox scroll problem
    ... As I make various entries in a program (in text boxes), ... When it is full the scroll bar appears, but I continue to see only the first entries, and have to use the scroll bar to see the latest. ... Unless I am missing something in your request, just execute the line of code I gave you right after you execute the line of code you showed above. ...
    (microsoft.public.vb.general.discussion)