Using Global Save and Load Events

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 Form1()
{
    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("..\\..\\Reports\\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");
}