Question
“How can I implement default report settings for new reports created by end-users? And for existing reports?”
Solution
The following example uses the Report.Template OnNew and OnLoadEnd events to implement default report properties.
Download: DesignerInitializeReportProperties.zip
Sample Delphi code:
procedure TForm1.Button1Click(Sender: TObject);
begin
// initialize report properties
InitializeReport(ppReport1);
// assign template event-handlers
ppReport1.Template.OnNew := ehTemplate_New;
ppReport1.Template.OnLoadEnd := ehTemplate_LoadEnd;
ppDesigner1.ShowModal;
end;
procedure TForm1.ehTemplate_LoadEnd(Sender: TObject);
begin
InitializeReport(ppReport1);
end;
procedure TForm1.ehTemplate_New(Sender: TObject);
begin
InitializeReport(ppReport1);
end;
procedure TForm1.InitializeReport(aReport: TppReport);
begin
// initialize report properties
aReport.SaveAsTemplate := True;
aReport.AllowPrintToFile := True;
aReport.EmailSettings.Enabled := True;
aReport.PreviewFormSettings.WindowState := wsMaximized;
end;