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

Runtime Group Creation

edited September 2006 in General
Hi,

Is it possible to create a group at runtime?

I want to give the users the ability to add groups at runtime, by clicking
buttons.

I have tried the following code:

var
Group : TppGroup;
begin
Group := TppGroup.Create(nil);
Group.BreakName := 'CAMPO';
Group.DataPipeline := DataPipeline;
Group.KeepTogether := True;
Relatorio.AddGroup(Group);
Relatorio.PrintToDevices;
end;

But it gives a violation error. In RB help it says that we should not call
the addGroup method. So how do I add a group at runtime?

Thanks in advance

Comments

  • edited September 2006

    Below is a tech tip, check out the Code Based thread of the tech tips
    newsgroup for more articles on creating reports in code.

    ----------------------------------------------------
    Tech Tip: Create a Group in Code
    ----------------------------------------------------


    How can I dynamically create a report group at run-time?


    example code:
    -------------

    uses
    ppClass, ppGroup, ppClasUt;


    function AddGroupToReport(aBreakName: String; aDataPipeline:
    TppDataPipeline; aReport: TppCustomReport);
    var
    lGroup: TppGroup;
    lGroupBand: TppGroupBand;

    begin


    {add group to report}
    lGroup := TppGroup(ppComponentCreate(aReport, TppGroup));

    lGroup.Report := aReport;

    lGroup.BreakName := aBreakName;
    lGroup.DataPipeline := aDataPipeline;

    {add group header and footer bands }
    lGroupBand := TppGroupBand(ppComponentCreate(aReport,
    TppGroupHeaderBand));
    lGroupBand.Group := lGroup;

    lGroupBand := TppGroupBand(ppComponentCreate(aReport,
    TppGroupFooterBand));
    lGroupBand.Group := lGroup;


    end; {procedure, AddGroupToReport}


    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com




    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2006
    Im using RB 9.01... Delphi could not find unit ppGroup.

  • edited September 2006
    Problem solved!...

    Thanks for the reply...

This discussion has been closed.