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

Centerize text to page

edited October 2005 in General
I have a report that has a bunch of labels in the Title band. The
print height and width varies since it is modified by code in screen
pixels. How do I centerize all the labels to be in the center of the
page? Can I create something like a textbox that holds all the
labels and then just centerize the textbox in the page by code?
How do I create a textbox? Is a Region equivalent to a textbox?

Thanks in advance.

Andy

Comments

  • edited October 2005
    Hi Andy,

    You can find the width and height of a page using the
    Report.PrinteSetup.PageDef property. If you would like to use screen
    pixels, see the spPrintableWidth. Using this value (perhaps in the
    Report.BeforePrint event), you could loop through each label inside the
    Title band and move it to the center as needed. See the article below on
    how to loop through report components.

    ----------------------------------------------
    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
  • edited October 2005
    Hi Nico,

    Thanks so much for the tip. I'll give it a shot and see how it comes out.

    Thanks again.
    Andy

This discussion has been closed.