文檔首頁>>Stimulsoft Reports.WinForms教程-2019>>Stimulsoft Reports.WinForms教程:顯示報表創(chuàng)建進(jìn)度
Stimulsoft Reports.WinForms教程:顯示報表創(chuàng)建進(jìn)度
立即點(diǎn)擊下載Stimulsoft Reports.Ultimate最新版
本示例說明如何顯示生成報表的自定義進(jìn)度。顯示進(jìn)度條對于復(fù)雜的報表或包含大量數(shù)據(jù)的報表很有用。您可以使用報表對象的渲染事件:
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(); }
在下面的屏幕截圖中,您可以看到示例代碼的結(jié)果。