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

Removing programmatically added labels before next print

edited March 2005 in General
I am adding label components to a report programmatically, then printing it.
The program then needs to clear these added labels so it can add new ones
for the next report. I've tried looping through ppReport1.components, and
then it dawned on me that the labels are actually added to the detail band.
So now, I'm trying this:

b := ppReport1.getband(btDetail);
for i:=0 to b.componentcount-1 do
while b.components[i].tag=-1 do b.components.free;

Note that I've set the tags on the added components to -1 at the time of
creation.

Problem is, the band's component count seems to be 0. Where are the labels
I added?

Jeremy

Comments

  • edited March 2005
    This is insane, I must be losing my mind. In the D7 object inspector, I see
    many, many label components belonging to ppDetailBand1, yet when the program
    is running, the componentcount is 0. What is happening here?

    Jeremy

  • edited March 2005
    Hi Jeremy,

    ----------------------------------------------
    Tech Tip: Loop Thru All Objects in a Report
    ---------------------------------------------

    A ReportBuilder report is composed of a set of components. The basic
    structure is

    Reports.Bands[].Objects[]

    The bands and objects within the report can be accessed directly by object
    name or via the Bands and Objects array properties.

    Below is an example of using the Bands and Objects array properties to
    change the font for all objects on a report.


    uses
    ppClass;


    procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;

    begin

    for liBand := 0 to aReport.BandCount-1 do

    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    if lObject.HasFont then
    lObject.Font := aFont;

    end;

    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.