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

Adding Labels at Runtime

edited May 2007 in General
This seems like a simple thing to do, but I can't seem to make it happen. I
want to design an app that builds a simple, table-style layout report at
runtime without user interaction. I have a Delphi ListBox object on a form,
and a JITPipeline object that gets its data from this ListBox. What I want
to do is add TppLabel and TppDBText fields to a report for each field in the
PipeLine *at runtime* Unfortunately, I can't seem to see the data on the
report itself.

Here's a brief sample of my code, can anyone see what I am missing?

for i := 0 to PipeLine.FieldCount-1 do
begin
//Create Report Headers
NextLabel := TppLabel.Create(Self);
NextLabel.Caption := PipeLine.Fields[i].FieldAlias;
Nextlabel.Font.Name := 'Arial';
Nextlabel.Font.Size := 9;
NextLabel.Font.Style := [fsBold];
NextLabel.Top := 0;
NextLabel.Left := HorizPos;
NextLabel.AutoSize := FALSE;
NextLabel.Width := PipeLine.Fields[i].FieldLength;
HeaderBand.AddObject(NextLabel);

//Create Report Data Fields
NextData := TppDBText.Create(Self);
NextData.DataPipeline := PipeLine;
NextData.DataField := PipeLine.Fields[i].FieldAlias;
NextData.Font.Name := 'Arial';
NextData.Font.Size := 9;
NextData.Font.Style := [];
NextData.Top := 0;
NextData.Left := HorizPos;
NextData.AutoSize := FALSE;
NextData.Width := PipeLine.Fields[i].FieldLength;
DetailBand.AddObject(NextData);

HorizPos := HorizPos + List.ColWidths[i] + 5;
end;

PipeLine.RecordCount := List.RecCount;

Comments

  • edited May 2007
    Answering my own question:

    The key is to set NextLabel.Band := HeaderBand instead of calling
    HeaderBand.AddObject. Found this in an older post after coming up with a
    different search term...

    Kimberly

This discussion has been closed.