Create Group in Code

TECH TIP: Create a Group in Code

Question: “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}