By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

Added items to listbox but display only newest items

P: n/a
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.

Oct 18 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a

ags5406 wrote:
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/combob...ingListbox.asp - use
to set the scroll to where you want it

Oct 18 '07 #2

P: n/a
Try using the ScrollIntoView(item) after adding the item.
ags5406 wrote:
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.
Oct 18 '07 #3

P: n/a
Try using the ScrollIntoView(item) after adding the item.

ags5406 wrote:
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.
Oct 18 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.