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

GetSubReports

edited July 2002 in General
I am loading templates dynamically. When load I call ppReport.GetSubReports
so I can get a list of sub reports. Through the object property I cast to a
TppSubReport and set the OnPrint event to a method on my form ( procedure
DoStuff(Sender: TObject) ) but this isn't being called. If I set up a report
in code a wire up the event handlers within the IDE it works fine.

Any help greatly appreciated

Comments

  • edited July 2002
    When are you doing this assign. The optimal place to do it is in the
    Template.OnLoadEnd event.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited July 2002
    I have now tried it here and it still fails to call the event. It's a
    standard TNotifyEvent so I can't see why it would get called this way. Is it
    actually possible to wire up an event this way as maybe the getsubreports
    doesn't actually give you a handle to the subreports that are about to be
    used. Are they a copy?


    "Alexander Kramnik (Digital Metaphors)" wrote
  • edited August 2002
    GetSubreports actually returns a list of the report objects associated with
    the subreport, not the subreport itself. Try the code below:

    var
    lSubreports: TStringList;
    liIndex: Integer;
    begin
    lSubreports := TStringList.Create;
    ppReport1.GetSubReports(lSubreports);
    for liIndex := 0 to lSubreports.Count-1 do

    TppSubReport(TppChildReport(lSubreports.Objects[liIndex]).Parent).OnPrint :=
    ppSubReport1Print;
    lSubreports.Free;
    end;

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.