文档彩票走势图>>Stimulsoft Reports.WinForms教程-2019>>Stimulsoft Reports.WinForms教程:显示报表创建进度
Stimulsoft Reports.WinForms教程:显示报表创建进度
立即点击下载Stimulsoft Reports.Ultimate最新版
本示例说明如何显示生成报表的自定义进度。显示进度条对于复杂的报表或包含大量数据的报表很有用。您可以使用报表对象的渲染事件:
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { DataSet data = new DataSet(); data.ReadXml("..\\..\\Data\\Demo.xml"); report.RegData(data); using (var stream = Assembly.GetExecutingAssembly(). GetManifestResourceStream("SampleProgress.Master-Detail-Subdetail.mrt")) { report.Load(stream); } report.Compile(); report.CompiledReport.Rendering += new EventHandler(CompiledReport_Rendering); report.Render(false); } void CompiledReport_Rendering(object sender, EventArgs e) { if (label1.InvokeRequired) label1.Invoke((EventHandler)delegate { label1.Text = report.StatusString; }); else label1.Text = report.StatusString; }
要生成报表,您可以使用该线程。button1_Click事件添加必要的处理程序并启动线程。渲染后,报表将显示在查看器中:
private void button1_Click(object sender, EventArgs e) { backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork); backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted); backgroundWorker1.RunWorkerAsync(); label1.Text = ""; label1.Visible = true; progressBar1.Visible = true; while (backgroundWorker1.IsBusy) Application.DoEvents(); } void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { label1.Visible = false; progressBar1.Visible = false; report.Show(); }
在下面的屏幕截图中,您可以看到示例代码的结果。