[Lazarus] StringGrid performance problems

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Nov 18 08:47:40 CET 2010

Op 2010-11-18 00:19, Jesus Reyes het geskryf:
> Sure, I think it can be improved but currently I have other priorities.

Understood, I just wanted to know if it was a known problems. For the LCL
version of my app, I'll try the ListView (or TreeView like Lazarus IDE does).

> I was trying to find documentation about fpGUI stringgrid

There is none for the grids. I'm almost done with the corelib class
documentation, then I'll start on the GUI components. Writing decent
documentation takes longer than I expected. Now I fully respect the effort
Michael put in to write the RTL and FCL docs.

> couldn't find it, I tried looking at the code in sf site, it seems fpGUI
> stringgrid has a limited set of features compared to lazarus (or delphi)
> stringgrid, for example I didn't see in the code how you can set
> variable row height, or fixed cols/rows.

Row height can be set via DefaultRowHeight property. I have not found a use
for variable height rows (one row taller than another), but it is easy to
add if the need arises (all the infrastructure code is there). Even in the
8 year of working with Delphi, I've never used that either. If content
doesn't fit, use a tooltip - that's the normal behaviour users expect.

Fixed rows are handled differently in fpGUI. Fixed rows are not part of the
rowcount in fpGUI. They are separated out, and have their own dedicated
properties to adjust the header style, content, width etc.

Fixed columns are treated simply as normal grid column, but by disabling
keyboard or mouse focus in them. The look can be adjusted by the developer
to suite their needs (flat, medium, button, greyed, any color or look etc).
This also allows "fixed columns" to appear anywhere in the grid, not just
on the left edge.

> Just for fun and because columns seems to support variable width, can
> you do the same test but instead of rows use cols?, I mean instead of
> rowcount:=x do colcount := x and do cell[i, 0] := xstr

7 seconds for 8 million columns.  See attached screenshots.

----------[ the code ]----------------------
procedure TMainForm.ButtonClicked(Sender: TObject);
 i: integer;
  for i := 1 to 8000000 do
    Grid1.ColumnCount := i;
    Grid1.Cells[i-1,0] := InttoStr(i);
  lblTime.Text := et.ElapsedDHMS;
------------------[ end ]-------------------

  - Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

-------------- next part --------------
A non-text attachment was scrubbed...
Name: MainForm_001.png
Type: image/png
Size: 3604 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20101118/274f7858/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MainForm_002.png
Type: image/png
Size: 3519 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20101118/274f7858/attachment-0007.png>

More information about the Lazarus mailing list