How do you deal with large lists?

Forgive me but you started this conversation saying that 3000 records took too long to load. When I asked for clarification, you used 50,000 rows to match that number. With a little math

3000 \ 50000 * 3

We get 0.18 seconds to load 3000 records. Now it might have taken longer because there is some overhead in the initial query of a rowset, but not enough to be noticeable in this case.

So what was it about your initial test that brought this up?

It should be noted that just adding rows to a listbox is very time consuming. If you’re going to reload data, you might want to avoid using RemoveAllRows, just overwrite the data that’s already there and only add/remove rows from the end as necessary. This technique can make a huge difference in performance.

No, I buy code or use plugins where I can. Getting a data-aware listbox right takes weeks.

Added this method to a window:

Public Sub FillListBox()
  StartTime = Microseconds
  #Pragma BackgroundTasks False
  #Pragma DisableBackgroundTasks
  #Pragma DisableBoundsChecking
  Listbox1.Visible = False
  For i As Integer = 1 To NumberOfRows
    ListBox1.AddRow ""
    ListBox1.RowTag(Listbox1.LastIndex) = i 
  Listbox1.Visible = True 
  #Pragma BackgroundTasks True
  EndTime = Microseconds
  MsgBox "This took " + Str((EndTime - StartTime) / 1000000) + " sec"

End Sub

To add 50,000 rows and set the rowTag for each added row on my old Mac Pro from 2010 (the single core performance is pretty low):

2.9 sec WITHOUT changing the ListBox visibility
0.39 sec WITH changing the ListBox visibility


You’re right. It wasn’t an exact match to my original issue which prompted me to look for alternatives. My table had a lot more columns than just six and I think that may be what caused the slow down. I was saving a copy of the data class instance as the RowTag on each row as well as filling in the text for the columns displayed. While the listbox may have only had a handful of columns, the object had 20+ properties.

3000 rows is nearly instantaneous so I’m going to do some more stress testing to figure out exactly what the slow down was.

Thankfully, this thread has brought some new ideas to my attention so I want to try them as well. As I’m programming/learning I often wonder if there isn’t something that I’m missing (there often is) that everyone else seems to know that I don’t… that’s when I come here. :wink: