Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-11

String Grid Component

7 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Torsten Bonde Christiansen

Hi List.

I am looking for grid component that can display string. Simple enought and i know of a few already, but the ones i know of cannot do both of the following requirements i have:

a) Fast (very low delay on 100.000+ lines of test) b) Allow selecting multiple cells spanning rows and colomns.

For a) i know of VirtualTreeview which handles large data very very fine. The problem is that is does not allow for selecting multiple columns and rows combined.

For b) there is the native LCL stringgrid, the lazarus package TKontrols is also good, but they don't handle large data very well. Mostly because all rows/columns are traversed (initialized) instead of the just the actual rows/columns displayed onscreen.

So i am asking if you know of a good string grid component that can handle both things equally well.

Kind regards,
Torsten.

Reply by email

Werner Pamler
to Torsten Bonde Christiansen: Hi List. I am looking for grid component that can display string. Simple enought and i…
Torsten Bonde Christiansen wrote 15 lines
I am looking for grid component that can display string. Simple enought and i know of a few already, but the ones i know of cannot do both of the following requirements i have: a) Fast (very low delay on 100.000+ lines of test) b) Allow selecting multiple cells spanning rows and colomns. For a) i know of VirtualTreeview which handles large data very very fine. The problem is that is does not allow for selecting multiple columns and rows combined. For b) there is the native LCL stringgrid, the lazarus package TKontrols is also good, but they don't handle large data very well. Mostly because all rows/columns are traversed (initialized) instead of the just the actual rows/columns displayed onscreen.

(a) What is "fast"? If I populate a standard TStringGrid with 100.000 rows x 100 columns (= 10 millions of cells) it takes about 9 seconds on my PC - if BeginUpdate/EndUpdate is used. Not too bad in my eyes. If it's too long you should use a TDrawGrid and paint the cells in the OnDrawCell event. Since this draws only the visible cells it will occur within the blink of an eye. Editing a TDrawGrid is a bit more complicated, though, but doable.

(b) Multiselection has been added to the LCL grids (StringGrid and DrawGrid) some time ago. Set option goRangeSelect, and - if the cells selected are not contiguous - change RangeSelectMode to rsmMulti. Then you can select individual cells by Ctrl- and Shift-Clicks like you know from Excel.

Of course you should ask yourself the question: Is a grid with millions of cells really something a user wants to work with?

Reply by email

Werner Pamler
to Werner Pamler
Werner Pamler wrote 7 lines
(a) What is "fast"? If I populate a standard TStringGrid with 100.000 rows x 100 columns (= 10 millions of cells) it takes about 9 seconds on my PC - if BeginUpdate/EndUpdate is used. Not too bad in my eyes. If it's too long you should use a TDrawGrid and paint the cells in the OnDrawCell event. Since this draws only the visible cells it will occur within the blink of an eye. Editing a TDrawGrid is a bit more complicated, though, but doable.

I forgot: Of course, this does not take into account the time it takes to populate the primary storage of the data shown in the DrawGrid. Filling a 2D-array with millions of strings, for example, will take its time too, 6 seconds on my PC for a 100.000 x 100 array. In these tests, the string is assembled as 'R' + IntToStr(rowindex) + 'C' + IntToStr(colIndex).

Look at attached demo.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: huge_grid.zip
Type: application/x-zip-compressed
Size: 2585 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171127/94f50ad3/attachment-0001.bin>

Reply by email

Torsten Bonde Christiansen
to Werner Pamler
Werner Pamler wrote 15 lines
Am 27.11.2017 um 16:21 schrieb Werner Pamler via Lazarus: > (a) What is "fast"? If I populate a standard TStringGrid with 100.000 > rows x 100 columns (= 10 millions of cells) it takes about 9 seconds > on my PC - if BeginUpdate/EndUpdate is used. Not too bad in my eyes. > If it's too long you should use a TDrawGrid and paint the cells in > the OnDrawCell event. Since this draws only the visible cells it will > occur within the blink of an eye. Editing a TDrawGrid is a bit more > complicated, though, but doable. I forgot: Of course, this does not take into account the time it takes to populate the primary storage of the data shown in the DrawGrid. Filling a 2D-array with millions of strings, for example, will take its time too, 6 seconds on my PC for a 100.000 x 100 array. In these tests, the string is assembled as 'R' + IntToStr(rowindex) + 'C' + IntToStr(colIndex).

Yes, sorry for the lack of other factors too - those were just the two most needed.

I already have the data at hand in my own object structure so that is no problem. By fast i mean less than one second, even on a modern PC. The users of our program often have old or very old hardware in which case my/your 9 seconds turns to 30 or more seconds.

In reallity all i need is a read-only grid that can display the data in string format and range selection so that i can copy/paste the data to the clipboard.

From your reply it seems i am going with TDrawGrid.

Thank you for the help!

Regards,
Torsten.

Show quoted text 5 lines
Look at attached demo.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171127/9406344a/attachment.html>

Reply by email

Werner Pamler
to Torsten Bonde Christiansen
Torsten Bonde Christiansen wrote
[...]  so that i can copy/paste the data to the clipboard.

Hmm... You must be aware that the DrawGrid does not own any data. Therefore it cannot copy anything to the clipboard. You'll have to write clipboard access by yourself - which is not too difficult I guess.

Reply by email

Torsten Bonde Christiansen
to Werner Pamler
Werner Pamler wrote 8 lines
Am 27.11.2017 um 17:51 schrieb Torsten Bonde Christiansen via Lazarus: > [...]  so that i can copy/paste the data to the clipboard. Hmm... You must be aware that the DrawGrid does not own any data. Therefore it cannot copy anything to the clipboard. You'll have to write clipboard access by yourself - which is not too difficult I guess.

Yes i am aware of that, all i need to know is which cells are selected in order to copy the data.

But thanks for the information :)

Regard,
Torsten.

Reply by email