kryslt / KControls

Free components for Delphi and Lazarus, this is the main repository maintained by the original author.
BSD 3-Clause Clear License
59 stars 32 forks source link

Performance issue when selecting rows/columns... #28

Closed AzzaAzza69 closed 9 months ago

AzzaAzza69 commented 4 years ago

I hold shift and page down until approx 500 rows are selected, then cursor right to extend selection into more columns (still holding shift), it gets slower and slower as more columns are selected. The effect takes longer to manifest when less rows are selected.

kryslt commented 4 years ago

Not a bug. Longer time is natural due to the nature of the calculation of the block of selected cells.

AzzaAzza69 commented 4 years ago

Hmph. Ok. My users need to be able to select several hundred rows + columns...looks like I'll have to change to stringgrid as this doesn't exhibit any kind of slow down regardless of the number of rows/columns/selection. I would have thought it only needs to calc the block of selected cells that are visible on screen (in my case 20 rows) and not the 480 offscreen rows...

kryslt commented 4 years ago

Ok then, how slow is it? It is always slower to manage thousands of cells than a few of them, regardless of all possible optimizations. Moreover, KGrid has still more features than StringGrid IMO, maybe it is because of these? Anyway, when I test with KGridDemo in Delphi, add 5000+ rows, try those selections you described, then I experience no significant delays. Please attach example that demonstrates this issue if you are not able to demonstrate this issue in KGridDemo. Then reopen this issue.

kryslt commented 4 years ago

Reopening this myself, is a pending performance issue. Please refer to #10 and #19, to fix these huge work would be needed. Here you only report about several hundreds of rows. And this should be fast enough. Maybe it is bound to some specific drawing feature in each cell that takes a long time to compute? Please attach example that demonstrates this issue, if possible.

kryslt commented 4 years ago

Finally could reproduce the issue myself, no need to attach example. Located problem in TKCustomGrid.PaintCells, line TmpBlockRect := InternalGetSelectionsRect(J, I); Once commented out, selections are fast. It seems that this issue was not always there but appeared after some third party modification. Will keep an eye on that and fix this.

AzzaAzza69 commented 4 years ago

Yeah - that's it. It looks through the list of selected cells for EVERY single cell being painted.

kryslt commented 9 months ago

Has been fixed in 1dcbcd5 and ea06ff4. There were many issues causing this mainly because of the grid complexity, eg. a slow calculation of range selection to be painted.