Back to Devexpress

PrintTool.ShowRibbonPreviewDialog() Method

windowsforms-devexpress-dot-xtraprinting-dot-printtool-43462717.md

latest9.1 KB
Original Source

PrintTool.ShowRibbonPreviewDialog() Method

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

Namespace : DevExpress.XtraPrinting

Assembly : DevExpress.XtraPrinting.v25.2.dll

NuGet Package : DevExpress.Win.Printing

Declaration

csharp
public void ShowRibbonPreviewDialog()
vb
Public Sub ShowRibbonPreviewDialog

Remarks

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

The ShowRibbonPreviewDialog 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 ShowRibbonPreviewDialog 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 ShowRibbonPreviewDialog 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.PreviewRibbonForm property.

Example

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

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.

csharp
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 Ribbon Print Preview form modally, 
        // and load the report document into it.
        printTool.ShowRibbonPreviewDialog();

        // Invoke the Ribbon Print Preview form
        // with the specified look and feel setting.
        printTool.ShowRibbonPreviewDialog(UserLookAndFeel.Default);
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.LookAndFeel
Imports DevExpress.XtraReports.UI
' ...

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

    Using printTool As New ReportPrintTool(report)
        ' Invoke the Ribbon Print Preview form modally, 
        ' and load the report document into it.
        printTool.ShowRibbonPreviewDialog()

        ' Invoke the Ribbon Print Preview form
        ' with the specified look and feel setting.
        printTool.ShowRibbonPreviewDialog(UserLookAndFeel.Default)
    End Using
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the ShowRibbonPreviewDialog() 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.

reporting-winforms-create-hierarchical-report-in-code/CS/CreateHierarchicalReport/Program.cs#L15

csharp
ReportPrintTool printTool = new ReportPrintTool(report);
    printTool.ShowRibbonPreviewDialog();
}

reporting-winforms-export-options-actions/CS/ExportOptionSample/Form1.cs#L85

csharp
preview.PrintingSystem.AddCommandHandler(new CustomPDFExportCommandHandler());
    preview.ShowRibbonPreviewDialog();
}

winforms-reporting-create-report-bound-to-xpobjectsource/CS/Form1.cs#L53

csharp
ReportPrintTool printTool = new ReportPrintTool(report);
    printTool.ShowRibbonPreviewDialog();
}

reporting-winforms-add-vertical-brick/CS/T457705/Form1.cs#L13

csharp
ReportPrintTool tool = new ReportPrintTool(report);
    tool.ShowRibbonPreviewDialog();
}

reporting-winforms-use-subreport-to-add-a-chart/CS/Reporting-Use-Subreport-To-Add-A-Chart/Form1.cs#L27

csharp
// Print Preview loads the report.
printTool.ShowRibbonPreviewDialog();
Application.Exit();

reporting-winforms-export-options-actions/VB/ExportOptionSample/Form1.vb#L85

vb
preview.PrintingSystem.AddCommandHandler(New CustomPDFExportCommandHandler())
    preview.ShowRibbonPreviewDialog()
End Sub

winforms-reporting-create-report-bound-to-xpobjectsource/VB/Form1.vb#L52

vb
Dim printTool As New ReportPrintTool(report)
    printTool.ShowRibbonPreviewDialog()
End Sub

reporting-winforms-add-vertical-brick/VB/T457705/Form1.vb#L14

vb
Dim tool As New ReportPrintTool(report)
    tool.ShowRibbonPreviewDialog()
End Sub

reporting-winforms-use-subreport-to-add-a-chart/VB/Reporting-Use-Subreport-To-Add-A-Chart/Form1.vb#L26

vb
' Print Preview loads the report.
printTool.ShowRibbonPreviewDialog()
Application.Exit()

reporting-winforms-crosstab-runtime/VB/Form1.vb#L25

vb
' Shows the Print Preview.
    tool.ShowRibbonPreviewDialog()
End Using

See Also

Print Preview with a Ribbon Toolbar

Print Preview with a Standard Toolbar

ShowPreviewDialog

PrintTool Class

PrintTool Members

DevExpress.XtraPrinting Namespace