Hello all; I have been utilizing ListBox quite often to hold and manipulate data instead of just displaying it. I understand I really should be using an array or something more suited for that sort of thing, but what’s done is done! It got me thinking: does anyone have experience “breaking” ListBox? How much data can I cram in there? This is all hypothetical of course, as I generally just deal with smallish CSV files, but I am curious how much a ListBox could comfortably hold without crashing the program/causing performance problems.
Anyone loading gobs of info into ListBox objects?
1000+ rows starts to get slow iirc.
the row limit gets lower as you add more columns.
For the weblistbox we limit data to 100 rows. Sometimes even less depending on columns. For desktop apps I usually try to limit the listbox to 1,000 rows. We tend to ‘page’ our data.
Keep in mind that using the listbox to store and manipulate data is usually incredibly slow. Every time you add a row it refreshes. Putting everything in to a data class will almost always result in faster execution. UI is usually the slow part.
If the application has the ListBox flagged as invisible, does it still render it? Would that avoid UI slowness? If it is invisible does it act more like an array, or does it behave the same as a regular ListBox except, well, invisible?
I realize having an invisible ListBox defeats the purpose of the ListBox altogether, but for the sake of understanding the shenanigans of Xojo I thought I’d ask!
Thanks for your guys’ replies! I will definitely remember the “Keep it below 1000” rule of thumb moving forward!
Making a desktop listbox invisible does indeed speed it up. There is still some overhead.
For web it doesn’t seem to make any difference as it still creates the html behind the scenes.
Use what’s responsive. In one app I limit to 5000 rows because that rebuilds quickly, and is more than I need at a time. But there’s 180000 total rows of data. Loading all of it takes about 3 seconds, yet once loaded the listbox scrolls, resizes, reacts without detriment.
[quote=220405:@Tim Parnell]1000+ rows starts to get slow iirc.
the row limit gets lower as you add more columns.[/quote]
May I add some comments (add more datea) ?
In fact, I have a ListBox who displays 9999 entries (a limit I’ve probably make many months ago). The ListBox is created dynamically (from Date Start to Date End)
No slow down at all.
One More Thing: That ListBox holds 7 columns. The only filled columns are Column(0): a Row # (so from 0 to 9999) and a Date Start (Column(2) who holds the Dates as SQLDate.
At last, yesterday I added a bit more data ( a title every 30, 60, 90 or 120 Rows) with a Date End, Two Names and an eventual comment.
If I didn’t had troubles with the merge feature, I never realized how much data I was dealing with !
So, IMHO, the ay I see the things, a ListBox will start to slowdown:
if you have too many rows
if you have too many columns
if each cell is filled (how many characters there are in each Rows / Columns).
Make intensive tests with the average (to Max) rows / columns filled with text data.
And I do not talk about fancies: CheckBox, background images, background colours, two or more lines, Text size, Text styles, detection of a tag to set the background colour (or Text colour) to a predefined value and I certainly forgot some
I am using a lot of rows right now (over 1000), but with only a small amount of data in the two columns. I don’t have any slow downs. I expect I can expand this database (CSV) for quite some time at this rate. If it gets too big I will rewrite to use an array or something like that, but for the needs of this project I believe the dirty solution of using a ListBox for my data will work fine.
I routinely test with 5000-10000 rows and have good performance.
Have a look at http://www.pidog.com/piDogScrollingCanvas/DataView.shtml . I can’t recommend Einhugur software’s DataGrid anymore because after years there is no retina support.
Update everyone: I am at around 7050 rows, two columns with no issues! I am reaching the end of the end of this project, so I probably won’t need to add much more data.
From my experience I agree with @Bob Keeney , don’t expect the listbox an unlimited number of rows full of data. It’s not the fastest ever seen. I remember a VB6 project where I had a listbox displaying the entire long contact-base of a the user while filtering as you type, it was very fast. Can’t do that again with Xojo desktop.
Remember @Kem Tekinay , long time not seen on the tihis forum, had a solution for it back in the RB days, which seems to be still available.
I have a working listbox with 225000 rows in it… and it’s still not slow even across internet
but there is a trick, there is a sqlite database behind, and I only display the visible rows
so it is a listbox that displays the datas, but only some 50-70 at a time
so for me there is no limit to the listbox
except the 256 columns ? to pass through that limit, you need to implement your listbox with a canvas or something else.
Paging is indeed the way to unlimited rows.
For more than 256 columns, I would try placing non horizontal scrolling listboxes next to each other, synchronized vertically, on a ContainerControl , and have the ContainerControl do the horizontal scrolling on the window.
If you want to use the listbox with a lot of rows (say 50k, 100k or more together with a lot of columns) the best is to decouple the listbox and the data.
Do not add the records to the listbox, keep then in an array (with an array, dictionary or entity class for each record) and add empty rows.
Have a listbox subclass with two additional events:
Event Rows() As Integer
Event Value(row As Integer, column As Integer) As String (for arrays as records)
Event Value(row As Integer, columnName As String) As String (for dictionaries or entity classes as records)
In the listbox subclass’s CellTextPaint check if it is the top left visible cell. If yes, raise the Rows event to know if the count of rows in the records array has changed. If true, remove rows or add them accordingly (by using AddRow without any argument!).
After that still in the CellTextPaint raise the Value event to receive the string to be displayed at row and column or row and columnName and use DrawString. Note that for an entity class one needs to add a method to the entity class to get the property value by name I use introspection, which is much faster (and shorter and more versatile) than a Select Case statement.
This all avoids the slowness of adding data to the listbox.
Scrolling is much faster.
You can filter the array locally while adding the records to the listbox forces a round-trip to the database.
An even faster approach is to not use Remove and AddRow to adjust the count of rows in the listbox to match the count of records in the data array. Just have as many rows as are visible on screen. Very complex to calculate, but once you have it, you can show arrays with 1 million records or more, the listbox will never slow down.
Actually the same technique can be used to manage more than 256 columns.
after thinking for about 5 minutes, I was coming back to say that !
you’re too fast for me, Michel !
I don’t need 256+ cols for now but I will try to use the same technique if I need it.
Have you seen the new ListBox limit under 2015r4 in term of columns ?
(no more only 64 columns)
[quote=241283:@Emile Schwarz]Have you seen the new ListBox limit under 2015r4 in term of columns ?
(no more only 64 columns)[/quote]
yes : 256 cols, it’s 4x better, but still can be an issue with some apps.
FYI it’s 2000 columns in an sqlite db, and you can change it up to 32767