文檔首頁(yè)>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】使用全局保存和加載事件
【Stimulsoft Reports.WinForms教程】使用全局保存和加載事件
【下載Stimulsoft Reports.Ultimate最新版本】
此示例顯示如何在代碼中使用“Save”和“Load”事件,您可以在應(yīng)用程序初始化時(shí)將事件監(jiān)聽器添加到StiOptions.Engine.GlobalEvents:
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); }
然后指定加載報(bào)表時(shí)要執(zhí)行的操作:
... 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; } ...
指定報(bào)表保存時(shí)要執(zhí)行的操作:
... private void GlobalEvents_SavingReportInDesigner(object sender, Stimulsoft.Report.Design.StiSavingObjectEventArgs e) { if (designerControl1.Report == null) return; e.Processed = true; designerControl1.Report.Save("Report.mrt"); }