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

Controlling fields position at runtime

edited February 2005 in General
Hi everybody...

Every object we put in the report (ppText, ppDBText, etc...) have their top
and left properties,

I need to put these values in a table so the user can modify it.
EJ:
Field Left Top
ppText2 25 16
ppText2 25 22

and so on...

How can I change the values of the objects in the report with the values in
the table before
print the report ?

Any help will be appreciatted.
Regards

Fita

Comments

  • edited February 2005
    Hi Jose,

    Try using the Band.BeforePrint event to adjust the position of each object
    in that band based on the values you retrieve manually from your dataset.
    You may also try the Component.OnPrint event but this may fire too late in
    some cases.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2005
    Thanks Nico...
    I have tried both options but with no results.
    1) In the HeaderBand beforePrint I cant't access the objects, where are
    they? (in Object TreeView
    the objects's symbol appears dimmed)
    2) I have try to write some code in RAP this way:
    Select headerband Events
    Right Click over BeforePrint and select new
    Write next code for the event
    begin
    DBText1.Left := 20;
    DBText1.Top := 50;
    end;

    but nothing happens...
    How ReportBuilder fires this procedure ?
    I must be call it from somewhere ?

  • edited February 2005
    Hi Jose,

    In order to access the objects, you will need to create a report object
    loop. See the article below for more information...

    ----------------------------------------------
    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 February 2005
    Thank you Nico...
    Regards.

This discussion has been closed.