Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PrintTool.ShowPreviewDialog(IWin32Window, UserLookAndFeel) Method

Invokes the standard Print Preview dialog showing the document that is created from a source (report or link) assigned to the PrintTool. The dialog is invoked using the specified look-and-feel settings.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.XtraPrinting.v24.2.dll

NuGet Package: DevExpress.Win.Printing

#Declaration

public void ShowPreviewDialog(
    IWin32Window owner,
    UserLookAndFeel lookAndFeel
)

#Parameters

Name Type Description
owner IWin32Window

A IWin32Window object that is the parent window for this dialog.

lookAndFeel UserLookAndFeel

A UserLookAndFeel object, specifying the look-and-feel settings applied to the Print Preview form.

#Remarks

Use the ShowPreviewDialog method to invoke the Print Preview dialog showing a report document.

XtraReport_ShowPreview.png

The ShowPreviewDialog 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 ShowPreviewDialog 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 ShowPreviewDialog 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);
    }
}
See Also