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

Load Template File the load image in ppImage ...

edited May 2007 in General
Hi All,

I am have a bit of a delimer.

I have have a ppReport component on my form which i load the template into
on the fly.

Once the template has been loaded from file, i the want to change 3 images
on the form before i call the print so the images are updated in the report
before i preview to the screen.

I have tried a few different ways with no success, has anyone had any luck.

Thanks in advance.



Trevor

Comments

  • edited May 2007
    Hi Trevor,

    I would recommend using the Template.OnLoadEnd event to alter a report after
    a template has been loaded. Take a look at the following article.

    ----------------------------------------------
    Tech Tip: Using Template Events
    ----------------------------------------------

    The Report.Template object has several events that can be used for
    customizing what happens when a report is loaded or saved:

    - OnLoadStart
    - OnLoadEnd
    - OnNew
    - OnSaveStart
    - OnSaveEnd


    The OnLoadEnd and OnNew events are often used to perform actions related to
    report and data initialization.

    The OnSaveEnd event is often used to save additional descriptive ("meta")
    data to the database each time the report is saved.

    Example:

    The Report.Template events are public and therefore must be assigned at
    run-time.


    1. In the private section of your form declaration you can declare an
    event-handler method:

    TForm = class(TForm)
    private
    procedure myTemplateOnLoadEndEvent(Sender: TObject);

    public

    end;


    2. In the Form.OnCreate event, you can assign the event-handler to the
    event:

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;

    end;


    3. Implement the event-handler method:

    procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
    begin

    {add code here to initial the report or data, etc. }
    ppReport1.PrinterSetup.MarginTop := 0.5;

    end;


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2007
    Thank Nico,

    That was exactly what i needed to do.

    Your a legend :)


    Trevor


This discussion has been closed.