发布时间 : 2018-09-25 10:10:48.000|阅读 553 次
概述:本文主要分别介绍了Stimulsoft报表中保存并加载Designer的事件。
相关链接:
【下载Stimulsoft Reports.WPF最新版本】
此示例显示如何在代码中使用“Save”和“Load”事件。您可以 在应用程序初始化时将事件侦听器添加到StiOptions.Engine.GlobalEvents:
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);
}然后指定加载报表时要执行的操作:
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;
}指定报表保存时要执行的操作:
private void GlobalEvents_SavingReportInDesigner(object sender, Stimulsoft.Report.Design.StiSavingObjectEventArgs e)
{
    if (designerControl1.Report == null) return;
    e.Processed = true;
 
    designerControl1.Report.Save("Report.mrt");
}示例代码的结果如下图所示:

购买Stimulsoft正版授权,请点击“咨询在线客服”哟!
渝ICP备12000582号-15/渝公网安备 50010702501010号