473,796 Members | 2,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Added items to listbox but display only newest items

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
3 4949

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.Selected Index = lstBox.Items.Co unt - 1
3. http://www.codeproject.com/cs/combob...ingListbox.asp - use
to set the scroll to where you want it

Oct 18 '07 #2
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9432
by: gdbjohnson-AT-yahoo-dot-ca-nospamplz | last post by:
I have a ListBox built of a simple custom object for the ListItems used to be able to hold a Data Value, and a Display Value, with accessors for each. I have overridden the ToString method to display the Display value. (Two examples that I have seen, including an MS example, suggest that the DisplayMember and ValueMember properties of the ListBox can be used in this way, I could not get it to work using the ListItems.Add method -...
1
361
by: | last post by:
Hi, I have a listbox called lstFolders. I select the folder names from a database and return them in ascending order. However, when I do the listbox.items.insert(0, new instance) method, the items that are supposed to come back on in ascending order are the exact opposite order. The first one is at the bottom of the list.
2
1448
by: Simon Prince | last post by:
Help I have a ASP:Listbox on a form. My page Adds items to this this via Client-Side Script only. Such as... var vObj_TargetElement = document.getElementById("_PageTemplate_innerHolder_oASP_Lbx_Invoice"); var vObj_SourceElement = document.getElementById("oHTML_Tbx_Invoice"); var vInt_OptionTotal = vObj_TargetElement.length++;
2
2438
by: cs_hart | last post by:
This is a newbie question. I use the following to add items to the list box. When I look at the box, I see rows have been added. I can scroll and select an item and obtain the row in the listbox handler. But there is no actual text in the box. I added the j variable just to see if the rows were being incremented. I didn't think I need the visible = true statement but added it just to be sure. This seems like elementry code so I'm sure...
9
7322
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the combobox, but I can't find anything that will let me do that. - Don
14
18758
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe is that as more and more are added, population of the list box takes longer and longer. ie the first 10th of the item set are added much much quicker than the last 10th. THis occurs with about 40,000 listbox items. My worry is the listbox may...
6
3965
by: Zytan | last post by:
In win32 there was a way to 'turn off' a listbox from updating until you were done adding elements. Is there a way to do this in .NET? Zytan
1
8306
by: Refugnic | last post by:
I tried to fill a ListBox with a DataSource pointing to an ArrayList. It all works fine...up to one point. The ArrayList is dynamic, which means the contents of it change, during the course of program use. But instead of Updating the ListBox, virtually nothing happens. The items that were written into the ListBox during the first run remain inside the ListBox, assuming the new values of the ArrayList. Obviously, if the new ArrayList is...
3
11737
by: kimiraikkonen | last post by:
Hi, I want to display ALL the items (includes unselected items) of listbox control. How can i code this? Should i use "for each" or other? For example: Assume you have a listbox with 3 items sth like: Hello There Guys
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.