Back to Devexpress

XtraReport.StopPageBuilding() Method

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-41ec5514.md

latest4.6 KB
Original Source

XtraReport.StopPageBuilding() Method

Interrupts the process of document creation.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public void StopPageBuilding()
vb
Public Sub StopPageBuilding

Remarks

When a document is being created in the background (by calling the XtraReport.CreateDocument method with the buildForInstantPreview parameter set to true ), you can interrupt the document creation at any moment by calling the StopPageBuilding method. All pages that have already been created prior to calling this method will be available in the XtraReport.Pages collection and can be displayed in the Print Preview, printed or exported.

Example

This example demonstrates how to generate report pages in background, so that pages that are ready are displayed in the PrintControl, and the progress bar shows the current state of report building. To do this, it is necessary to call the XtraReport.CreateDocument method, and pass true for its buildForInstantPreview parameter.

Regardless of the buildForInstantPreview parameter setting, a document will not be produced in a background thread. Document creation is not asynchronous, as parts of a document are rendered each time the Idle event is raised (in the WPF environment, a document is created using ticks from the DispatcherTimer class).

When this option is enabled, document creation can be interrupted by calling the XtraReport.StopPageBuilding method.

To perform this task, follow the steps listed below:

  1. Open Microsoft Visual Studio, and create a new Windows Forms Application , or open an existing project.
  2. Add a new blank report to it.
  3. Bind a report to data, so that it contains more than 1 page and its creation requires a significant amount of time.
  4. Drop a PrintControl onto a form, add two Button controls and handle a form’s Load event and buttons’ Click event as follows:
csharp
using System;
using System.Windows.Forms;
using System.Drawing.Printing;
// ...

XtraReport1 report;

private void Form1_Load(object sender, EventArgs e) {
    report = new XtraReport1();

    this.printControl1.PrintingSystem = report.PrintingSystem;
}

private void btnStart_Click(object sender, EventArgs e) {
    report.CreateDocument(true);
}

private void btnStop_Click(object sender, EventArgs e) {
    report.StopPageBuilding();
}
vb
Imports System
Imports System.Windows.Forms
Imports System.Drawing.Printing
' ...

Private report As XtraReport1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
Handles MyBase.Load
    report = New XtraReport1()

    printControl1.PrintingSystem = report.PrintingSystem
End Sub

Private Sub btnStart_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles btnStart.Click
    report.CreateDocument(True)
End Sub

Private Sub btnStop_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles btnStop.Click
    report.StopPageBuilding()
End Sub

Implements

StopPageBuilding()

See Also

CreateDocument

XtraReport Class

XtraReport Members

DevExpress.XtraReports.UI Namespace