This example shows how to display a custom progress for report building. Displaying the progress bar can be useful for complex reports, or reports with large amounts of data. You can use the Rendering() event of the report object:
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
	using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SampleProgress.MasterDetailSubdetail.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;
}

To build a report you can use the thread. The button1_Click() event adds necessary handlers and starts the thread. After rendering, the report will be shown in the viewer:
private void button1_Click(object sender, EventArgs e)
{
	backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
	backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
	backgroundWorker1.RunWorkerAsync();

	label1.Text = "Rendering...";
	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();
}

Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

Showing a Progress while Rendering a Report

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.