Back to Devexpress

PrintTool.ShowRibbonPreviewDialog(IWin32Window, UserLookAndFeel) Method

windowsforms-devexpress-dot-xtraprinting-dot-printtool-dot-showribbonpreviewdialog-x28-system-dot-windows-dot-forms-dot-iwin32window-devexpress-dot-lookandfeel-dot-userlookandfeel-x29.md

latest6.0 KB
Original Source

PrintTool.ShowRibbonPreviewDialog(IWin32Window, UserLookAndFeel) Method

Invokes the Ribbon Print Preview dialog showing the document that is created from a source (report or link) assigned to the PrintTool. The dialog is invoked as a child of the specified parent window, using the specified look-and-feel settings.

Namespace : DevExpress.XtraPrinting

Assembly : DevExpress.XtraPrinting.v25.2.dll

NuGet Package : DevExpress.Win.Printing

Declaration

csharp
public void ShowRibbonPreviewDialog(
    IWin32Window owner,
    UserLookAndFeel lookAndFeel
)
vb
Public Sub ShowRibbonPreviewDialog(
    owner As IWin32Window,
    lookAndFeel As UserLookAndFeel
)

Parameters

NameTypeDescription
ownerIWin32Window

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 Ribbon Print Preview form.

|

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

See Also

Print Preview with a Ribbon Toolbar

Print Preview with a Standard Toolbar

ShowPreviewDialog

PrintTool Class

PrintTool Members

DevExpress.XtraPrinting Namespace