Added items to listbox but display only newest items

  • Thread starter Thread starter ags5406
  • Start date Start date
A

ags5406

I've a listbox that I add items to at different points in the code.
It's height is such that only about 6 items can be displayed
vertically. The first item added shows up in the top line, then the
second item in the second line, etc.

After 6 items have been added, the vertical scroll bar appears and new
items continue to be added, but until the user actually moves the
scrollbar down the box displays only the first 6 items.

What I'd rather have happen is that as new items are added, each new
item shifts the list upward as the new item is added to the bottom
line. This way the user can monitor the items being added to the
listbox without touching the scrollbar. To see "hidden" items, the
user would move the scroll bar UP to see the earlier added items,
rather than down to see the later added items.

Hopefully this makes sense. Any ideas?

Thx.
 
ags5406 said:
I've a listbox that I add items to at different points in the code.
It's height is such that only about 6 items can be displayed
vertically. The first item added shows up in the top line, then the
second item in the second line, etc.

After 6 items have been added, the vertical scroll bar appears and new
items continue to be added, but until the user actually moves the
scrollbar down the box displays only the first 6 items.

What I'd rather have happen is that as new items are added, each new
item shifts the list upward as the new item is added to the bottom
line. This way the user can monitor the items being added to the
listbox without touching the scrollbar. To see "hidden" items, the
user would move the scroll bar UP to see the earlier added items,
rather than down to see the later added items.

Hopefully this makes sense. Any ideas?

Thx.

You have a few options here.
1. Don't use add but rather lstBox.Insert(0, itm)
2. lstBox.SelectedIndex = lstBox.Items.Count - 1
3. http://www.codeproject.com/cs/combobox/ScrollingListbox.asp - use
to set the scroll to where you want it
 
Back
Top