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

Changing Font for all labels in report

edited July 2005 in General
Hi

D7Pro, RBPro9.02

What is the quickest method to modify the Font.Color of all the labels of a certain colour in a report?

I am 'white labelling' a report, each client requires a different font.color

There are many levels of subreport, should I iterate through this hierarchy, or can I access all the pplabels directly through the form or report?

Any help much appreciated

Will

Comments

  • edited July 2005
    Hi Will,

    You are going to want to loop through every component in your report and
    change the font accordingly (see the article below). If you are using
    subreports, you will need to make this into a recursive call if you run
    across a subreport object.

    ----------------------------------------------
    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.