• <menu id="w2i4a"></menu>
  • logo Stimulsoft Reports.WinForms教程-2019

    文檔首頁>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】在線程中呈現(xiàn)報表

    【Stimulsoft Reports.WinForms教程】在線程中呈現(xiàn)報表


    【下載Stimulsoft Reports.Ultimate最新版本】

    此示例顯示如何在線程中呈現(xiàn)報表,在線程中呈現(xiàn)報表是在后臺進(jìn)程中運(yùn)行的,為此,使用BackgroundWorker類:

    private System.ComponentModel.BackgroundWorker backgroundWorker1;
     
    private void button1_Click(object sender, EventArgs e)
    {
        backgroundWorker1.RunWorkerAsync();
    }

    在backgroundWorker1_DoWork流程事件開始時,您可以卸載報表并連接數(shù)據(jù),還應(yīng)該訂閱已編譯的報表對象的Rendering事件:

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        using (var stream = Assembly.GetExecutingAssembly().
               GetManifestResourceStream("RenderInThread.Master-Detail-Subdetail.mrt"))
        {
            report.Load(stream);
        }
     
        DataSet data = new DataSet();
        data.ReadXmlSchema("..\\..\\Data\\demo.xsd");
        data.ReadXml("..\\..\\Data\\demo.xml");
     
        report.RegData(data);
        report.IsRendered = false;
        report.Compile();
        report.CompiledReport.Rendering += new EventHandler(CompiledReport_Rendering);
        report.Render(false);
    }

    在CompiledReport_Rendering事件中更新表單上的文本——顯示StatusString屬性的值,完成線程工作后,在查看器中顯示報表:

    void CompiledReport_Rendering(object sender, EventArgs e)
    {
        button1.Invoke((EventHandler)delegate { button1.Text = report.StatusString; });
    }
     
    private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        report.Show();
    }

    示例代碼的結(jié)果如下圖所示:

    Stimulsoft

    下載示例

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();