Added items to listbox but display only newest items

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.
 
G

ge0193387

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top