Hello group, I have this question. I work on a listbox, I load the rows one at a time with all the necessary data … there are many rows for each table. I have 5 ListBoxes and to fill them I use something like this:
ListBox(indexListBox).RemoveAllRows
While Not Rows.AfterLastRow
ListBox(indexListBox).AddRow(A,B,C,D,E,F,G)
rows.MoveToNextRow
Wend
I wanted to know if there is any “trick” to speed up the display. I noticed that with so much data it takes a few seconds …
Var start As Integer = System.Ticks
' Set to False, speeds up the Routine
ListBox(indexListBox).Visible = False
ListBox(indexListBox).RemoveAllRows
While Not Rows.AfterLastRow
ListBox(indexListBox).AddRow(A,B,C,D,E,F,G)
rows.MoveToNextRow
Wend
' Reset
ListBox(indexListBox).Visible = True
Var ended As Double = (System.Ticks - start) / 60
System.DebugLog(ended.ToString + " seconds")
A few things, why are you casting to ListBox all the time? ie “ListBox(indexListBox)”. Also with a tight loop like this try disabling background tasks:
#Pragma BackgroundTasks False
Var lb as ListBox = ListBox(indexListBox)
lb.RemoveAllRows
While Not Rows.AfterLastRow
lb.AddRow(A,B,C,D,E,F,G)
rows.MoveToNextRow
Wend
#Pragma BackgroundTasks True
Actually it is variable, it can go from 300 to 16000 lines … but by examining the code better I solved some repetition problems and with the two help of friends above, I greatly speeded up the display. For me it’s ok and it can go.