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):
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
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 |
To write code in C#
C# |
Copy Code
|
---|---|
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:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub _btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click c1r.Cancel = True Close() End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
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.