Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

TStringGrid Header Row

edited August 2002 in General
I have a report that uses a JITPipeline to print a TStringGrid. The first
row of the string grid is a header row that I do not want included on the
report. However, that row does contain some fields that are displayed in
the report header. I have included my GetFieldValue function below.
Everything seems to work except there is a blank row at the top of the
report. What am I doing wrong? Thanks in advance.

function TfrmForm1.ppJITPipelineGetFieldValue(aFieldName: String): Variant;
var
strFieldName: string;
iListIndex: integer;
begin
strFieldName := Uppercase(aFieldName);

iListIndex := ppJITPipeline.RecordIndex;

{if header row}
if iListIndex = 0 then
begin
if (strFieldName = 'RPTHEADERFIELD1') then
Result := edtHeader1.Text
else if (strFieldName = 'RPTHEADERFIELD2') then
Result := edtHeader2.Text
else
Result := '';
end
else {else not header row}
begin
if (strFieldName = 'RPTDETAILFIELD1') then
Result := Grid.Cells[0, iListIndex]
else if (strFieldName = 'RPTDETAILFIELD2') then
Result := Grid.Cells[1, iListIndex]
else if (strFieldName = 'RPTDETAILFIELD3') then
Result := Grid.Cells[2, iListIndex]
else
Result := '';
end;
end;

Comments

  • edited August 2002
    The detail band will print once for every 'record' - and in this case the
    header row is considered a record. Try setting the JITPipeline.InitialIndex
    to 1 , removing the if iListIndex = 0 logic from GetFieldValue entirely and
    manually assigning the header row values to TppLabel components in the
    header band (use the HeaderBand.BeforeGenerate event.) For more on this,
    see the JIT example (dm0139) in RBuilder\Demos\1. Reports - it is
    StringGrid-based and deals with this exact issue...

    --
    Cheers,

    Tom Ollar
    Digital Metaphors Corporation
This discussion has been closed.