文檔首頁>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】在Designer中保存和加載報(bào)表
【Stimulsoft Reports.WinForms教程】在Designer中保存和加載報(bào)表
【下載Stimulsoft Reports.Ultimate最新版本】
該示例顯示如何在代碼中使用“ Save”和“ Load”事件,您可以在應(yīng)用程序初始化時(shí)將事件偵聽器添加到StiDesigner類:
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; }
指定保存報(bào)表時(shí)要執(zhí)行的操作:
private static void OnSaving(object sender, StiSavingObjectEventArgs e) { StiDesigner designer = sender as StiDesigner; //string str = designer.Report.SaveToString(); MessageBox.Show("Report saved"); }
指定加載報(bào)表時(shí)要執(zhí)行的操作:
private static void OnLoading(object sender, StiLoadingObjectEventArgs e) { StiDesigner designer = sender as StiDesigner; //designer.Report.LoadFromString(str); MessageBox.Show("Report loaded"); }
示例代碼的結(jié)果如下圖所示: