Skip to main content

PrintTool.ShowPreview() Method

Invokes the standard Print Preview form showing the document that is created from a source (report or link) assigned to the PrintTool.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.XtraPrinting.v24.1.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.Printing

Declaration

public void ShowPreview()

Remarks

Use the ShowPreview method to invoke the Print Preview form showing a report document.

XtraReport_ShowPreview.png

The ShowPreview method internally generates a report document, if it is has not yet been created.

If the document has already been created when you call the ShowPreview method, it will not be re-created. For this reason, if the report has been changed, call the XtraReport.CreateDocument or Link.CreateDocument method prior to calling the ShowPreview method.

After closing the Print Preview form, it is required to explicitly dispose of the document source (report or link) assigned to the PrintTool.

The options of the Print Preview form are available via the PrintTool.PreviewForm property.

Example

In Windows Forms applications, you can show a document’s Print Preview by using the following methods of the ReportPrintTool: PrintTool.ShowPreview and PrintTool.ShowPreviewDialog.

This code will work in your application after you create a new report in it (named XtraReport1) and handle the Load event of the application’s main form.

using System;
using System.Windows.Forms;
using DevExpress.LookAndFeel;
using DevExpress.XtraReports.UI;
// ...

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

    using (ReportPrintTool printTool = new ReportPrintTool(report)) {
        // Invoke the Print Preview form modally, 
        // and load the report document into it.
        printTool.ShowPreviewDialog();

        // Invoke the Print Preview form
        // with the specified look and feel setting.
        printTool.ShowPreviewDialog(UserLookAndFeel.Default);
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the ShowPreview() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also