Slow ListBox with less than 100 rows…

Slow as a snail must be said.

The Paste time was correct (see/feels nothing),
but resizeing the colums to see all contents…

And I cannot say the data is huge (4 305 Bytes on disk); 8 columns.

App swap time too is huge.

Xojo 2024r4.2
Sequoia 15.3.2 (24D81)
50 GB of free rooms on the boot ssd.

And I wen there to edit a file (easier than with TextEdit). Usually. But unusable today.

I shutdown all applications.
Shut down the computer,
Let pass some minutes,
Boot, fire Disk Utilities: no trouble reported.

Fire Xojo,
Run
Load the txt file (speed seems OK, but so few bytes to load),
Tried to enlarge a Column slow as hell !

Well we all know you use some kind of customized listbox because of that time you forgot that you picked the colors.

Given your history, I am 100% sure there is code in your listbox that you wrote causing this problem.

Nothing fancy. I use Dark mode when I have visual troubles. But not today.

I do not modified that project since Feb 14, 2025.

What code can slow down a manual column resize ?

Screen shot:

I just noticed an error in the header (not related to speed).

If you can reproduce it in a sample project, please share the sample project.

2 Likes

Massive and/or inefficient code in the celltextpaint or cellbackgroundpaint events,
coupled with maybe a line of code that forces a refresh or repaint in those, so that each cell is painted over and over again.

Run profile and see what events are called thousands of times, and which ones take up the most time.

Try just commenting out the celltextpaint and cellbackgroundpaint event code as a starting point.

4 Likes

In the mean time (eat, drink, continue othe work) and then I decided to create a simple reader with ListBox.

So I go to the [LOCAL] documentation, ReadLine,takes the example and paste it in a fresh project file
(in a Open MenuEvent): OutOfBounds Errors.

Bad day for me: I am unable to understand what can be wrong in the example.

Before sending this, I check with the online help example if I get the same bad result.

Same.

https://documentation.xojo.com/api/files/textinputstream.html#textinputstream-readline

Done… I will try to work a little bit with this setting.

The sample code has a typo. Should be

ListBox1.CellTextAt(ListBox1.LastAddedRowIndex, i - 1) = oneCell

In fact, two changes ! I only saw one diference ( - 1), then look more carefully and see the other difference.

Thanks Martin.

PS: I need new eyes and a larger screen (I think at a MBA m4 15", for example).

As strange as it seems, removing commented lines in the CellBackgroundPaint Event resolve the trouble.
(of course, commenting the whole Event too).

Is it possible to see your CellBackgroundPaint

with or without comments ?

with !

In fact, it was not the commented code that was were the error lies.

I add garbage at the beginning of the Event, run : standard speed. I doubled the commented number of lines run: same standerd speed.

So I copy/pasted the defective code, removed the commented lines that does nothing: same slow.
So I compared line after line and diesovere a MessageBox, removed it and that was it.

I used System.DebugLog in that code (I think), but why a messagebox ?