List Box vertical scrolling

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hello,

I have a form & only a ListBox on it.
When it starts I have some other processes going on & I
have it updating the ListBox when each process is done so
user can see what is going on...

ListBox.AddItem "What is going on..."
DoEvents

This works fine.

As the number of items added goes past the number that
can fit in the screen the vertical scroll bars come up
which also is supposed to happen.

But what I would like to happen is when the above
happens, that the Vertical Scroll Bar changes to the
bottom automatically (through code) so user can see the
last items that were added not the top ones.

There must be some way to set the Vertical Scroll bar to
the bottom through code & keep doing this as more items
are added, but I have no idea on how to do so. How can
this be done ?

Any help would be greatly appreciated.

Thank you,
Jeff
 
As I don't know what other processes you are doing, I can't give code. But
one thing you might try is setting Selected property of the last value in
the List after you add a new value. That should select the last value in
the list, thus scrolling to the bottom.

Don't know for sure if it will work, but it's something to try.

--
--Roger Carlson
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Roger,

Thank you for the replay but what do you mean by
"setting Selected property of the last value" ?

Also maybe I was too complex in explaining, it doesnt
matter what procceses I am doing.

All I want to know is how to set the Vertical Scroll Bar
in a List Box

Thank you,
Jeff
 
Jeff

See if this floats your boat:

lstMyListBox.AddItem "What is going on..."
lstMyListBox.Value = "What is going on..."
lstMyListBox.Selected(lstMyListBox.ListIndex) = True
DoEvents

This should select the item you hust added and then make it the selected
item in the list (the one with the black background). This should cause the
list box to scroll in either direction so that the selection is visible in
the list.

Ron W
 
Hi Ron,

Thnx for the Reply but this doesnt work becuase the
ListIndex always stays as -1

Any way to change the code ?

Thx,
Jeff
 
Ron,

this works...

lstProcesses.Selected(lstProcesses.ListCount - 1) = True

You lead me to the right track so THANK YOU !!!

Jeff
 
Jeff

This should work. As Soon as you set the LisBox Value to the same data as
the data you just added to the bound column, the list index should change to
be the index of the item added. Please post ALL of the code that you are
currently using in the Subroutine.

Ron W
 
Back
Top