This sample shows how to use the Save and Load events in the code. You can add the event listeners to the
StiOptions.Engine.GlobalEvents
at application initialization:
public Window1()
{
StiOptions.Wpf.CurrentTheme = StiOptions.Wpf.Themes.Office2013Theme;
InitializeComponent();
StiOptions.Engine.GlobalEvents.SavingReportInDesigner +=
new Stimulsoft.Report.Design.StiSavingObjectEventHandler(GlobalEvents_SavingReportInDesigner);
StiOptions.Engine.GlobalEvents.LoadingReportInDesigner +=
new Stimulsoft.Report.Design.StiLoadingObjectEventHandler(GlobalEvents_LoadingReportInDesigner);
}
Then specify the action to be performed when the report is loading:
private void GlobalEvents_LoadingReportInDesigner(object sender, Stimulsoft.Report.Design.StiLoadingObjectEventArgs e)
{
e.Processed = true;
StiReport report = new StiReport();
report.Load("..\\SimpleList.mrt");
designerControl1.Report = report;
}
Specify the action to be performed when the report is saving:
private void GlobalEvents_SavingReportInDesigner(object sender, Stimulsoft.Report.Design.StiSavingObjectEventArgs e)
{
if (designerControl1.Report == null) return;
e.Processed = true;
designerControl1.Report.Save("Report.mrt");
}