ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Reports for WinForms Task-Based Help > Reporting Task-Based Help > Rendering Reports (Previewing, Printing, and Exporting) > Displaying a Progress Indicator While the Report Renders

Displaying a Progress Indicator While the Report Renders

Most preview applications have progress indicators that show which page is being rendered and have a button that allows the user to cancel the report while it is being generated. The .NET print preview controls provide this automatically for you. If you are printing the report directly to the printer or exporting it to a file, however, there is no built-in progress report UI.

Use C1Report events to create a progress report dialog, or to update a status bar while the report is being rendered. The StartPage and EndReport events are sufficient to provide feedback on which page is being printed and when the report is finished. For example, this code uses the StartPage event to provide feedback through a status bar (StatusStrip1):

      Visual Basic

Private Sub c1r_StartPage(ByVal sender As System.Object, ByVal e As C1.Win.C1Report.ReportEventArgs) Handles c1r.StartPage

       StatusStrip1.Text = String.Format("Rendering page {0} of '{1}'...", c1r.Page, c1r.ReportName)

End Sub

      C#

private void c1r_StartPage(object sender, ReportEventArgs e)

{

       statusStrip1.Text = string.Format("Rendering page {0} of '{1}'...",

       c1r.Page, c1r.ReportName);

}

To cancel the report before it is finished, add a Cancel button to your application and use it to set the C1Report.Cancel property to True. For example:

      Visual Basic

Private Sub _btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

   c1r.Cancel = True

   Close()

End Sub

      C#

private void _btnCancel_Click(object sender, System.EventArgs e)

{

       c1r.Cancel = true;

       Close();

}

Note that you may also want to provide progress bars and "page n of m" indicators, but that is generally difficult to do because the page count is not known until the report has been rendered.

* Sample Project Available

For a complete sample using a progress indicator, see the ProgressIndicator sample located on the ComponentOne HelpCentral Sample page.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.