Saving and Loading a Report in the Designer

The sample shows how to use the Save and Load events in the code. You can add the event listener to the StiDesigner class at application initialization:

static Form1()
{
StiDesigner.SavingReport += new StiSavingObjectEventHandler(OnSaving);
StiDesigner.LoadingReport += new StiLoadingObjectEventHandler(OnLoading);

//If you need you can hide menu item "Save As.."
StiMainMenuService service = StiMainMenuService.GetService();
service.ShowFileReportSaveAs = false;
}


Specify the action to be performed when the report will be saved:

private static void OnSaving(object sender, StiSavingObjectEventArgs e)
{
StiDesigner designer = sender as StiDesigner;
//string str = designer.Report.SaveToString();
MessageBox.Show("Report saved");
}


Specify the action to be performed when the report will be loaded:

private static void OnLoading(object sender, StiLoadingObjectEventArgs e)
{
StiDesigner designer = sender as StiDesigner;
//designer.Report.LoadFromString(str);
MessageBox.Show("Report loaded");
}


In the screenshot below you can see the result of the sample code.

Save and Load Report in Designer