Bad performance on tableGrid style
Hi,
I have a report that should print a sort of Gantt:
the query has a row for every project phase and there are 53 columns (one for the project name and theother 52 corresponds to weeks, their value is 1 or 0)
In the report I have a TableGrid with one Row and 53 columns in the Detail Section. I want the columns to be red if the corresponding value in the Query is 1, and blank if 0.
In the DetailBeforePrint Event I added this code:
It works, but it's terribly slow.
I added a showmessage at the end of the loop to get a feeling of the time it takes to complete one row. The thing I find strange is that the first rows are completed quite quickly, but it takes more and more time as we go on.
Did I make some terrible mistake? Is there a way to seed it up?
I have a report that should print a sort of Gantt:
the query has a row for every project phase and there are 53 columns (one for the project name and theother 52 corresponds to weeks, their value is 1 or 0)
In the report I have a TableGrid with one Row and 53 columns in the Detail Section. I want the columns to be red if the corresponding value in the Query is 1, and blank if 0.
In the DetailBeforePrint Event I added this code:
procedure DetailBeforePrint;
var
cellIndex: integer;
cell: TppTableCell;
value: integer;
begin
for cellIndex := 0 to TableRow.CellCount -1 do
begin
value := MyQuery[PadLeft(IntToStr(cellIndex+1), 2, '0')]; //This is because Query fields are '01' to '52'
cell := TableGrid.Cells[0, cellIndex] ;
if valore = 1
then cell.Brush.Color := clRed
else cell.Brush.Color := clWindow;
end;
showmessage('One row is done');
end;
end;
It works, but it's terribly slow.
I added a showmessage at the end of the loop to get a feeling of the time it takes to complete one row. The thing I find strange is that the first rows are completed quite quickly, but it takes more and more time as we go on.
Did I make some terrible mistake? Is there a way to seed it up?
Comments
procedure DetailBeforPrint;
var
cellIndex: integer;
cell: TppTableCell;
value: integer;
begin
for cellIndex := 0 to TableRow.CellCount -1 do
begin
value := TutteLeFasi_Corretta[PadLeft(IntToStr(cellIndex+1), 2, '0')]; //because fields are '01' ... '52'
cell := TableGrid.Cells[0, cellIndex] ;
if valore = 1
then cell.Brush.Color := clRed
else cell.Brush.Color := clWindow;
end;
showmessage('New Row created');
end;
end;
Is the code implemented in Delphi or the RB Calc workspace? If Calc workspace, try a test with Delphi code. If that is faster, create a RAP pass-thru function that can be called from Detail BeforePrint.
If you would like to create an example I can build and run in the debugger, I can research it. Please use standard Delphi components and RB. Copy data to TClientDataSets. Send zip, include only dpr, pas, dfm. Send to support@
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Anyway I will try to create an example of this to show you