Link to home
Start Free TrialLog in
Avatar of da4thrza
da4thrza

asked on

Maximum number of items in listview

I have an application where i am adding a large amount of items to a listview. my question is:
Is there a limit to how many items you can add to a listview or a treeview?
I need to add the items with a small icon.
By a large amount of items, im talking about in the 100,000 to 1,000,000 item range.
Can these controls handle this many items? I tried a loop that added 100,000 items to a listview and it took up an enormous amount of memory and ran terribly.
Are there any alternatives?
Avatar of webJose
webJose

Try www.vbaccelerator.com.  In there you can find a vitual listbox similar to outlook's listview for the message list (right pane).  The author claims it is a lot faster than a listview.
you could try using two list boxes, the first one holds a few categories, like i dont know what items you are talking about but say they were names then you could hold the letters of the alphabet in the first box and according to what the user chooses, you could change the second box.
ASKER CERTIFIED SOLUTION
Avatar of CarlosMu
CarlosMu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The ListView may hold as many items as your memory can hold. If speed is no problem, this will work on the swapfile, too.

Once, in one project of mine, I used the listview to show 100.000 items to the user from a database.
This took a lot of time to populate the listview (and also to clear all items in it ... ).

The _theoretical_ limit is: no limit. But around 100.000 items, you'll start having problems... :/
So. How to do this.

1. have a look at your application's design. Maybe you can filter out some items from the ones shown... Also, could be more useful to the end user less-items than 1.000.000 items (does he really needs all those?)

2. Build your own list view ... ! :) Actually, this is not a joke.

I build a "simple" listbox (yes, without columns), that is virtual. That is: you "tell" the list how many items you are going to store in it (e.g. 1.000.000 ): this does not allocate any memory, but it is used only to set up the scroll bar. Then, when you move the scroll bar around, you determine the starting row number and the number of rows that has to be shown, and display only those rows.
Of course, you'll have to store your data somewhere else (in a file for instance), since this "virtual" list will not store anything for you: it'll be only a "window" of some rows over the "big" data...

Here is an example of what I mean:

http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/Adding_Scroll_Bars_To_Forms__PictureBoxes_and_UserControls/article.asp

(yes, I know it talks about scrollbars ... but look at the related examples :) )


Hope this helps
M


: da4thrza -- You need to finish this question.
Avatar of DanRollins
Moderator, my recommended disposition is:

    Split points between: webJose and marconovaro

DanRollins -- EE database cleanup volunteer