Back to Devexpress

LayoutControl.Print() Method

windowsforms-devexpress-dot-xtralayout-dot-layoutcontrol-57ff87cf.md

latest3.4 KB
Original Source

LayoutControl.Print() Method

Prints the LayoutControl.

Namespace : DevExpress.XtraLayout

Assembly : DevExpress.XtraLayout.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public void Print()
vb
Public Sub Print

Remarks

The LayoutControl can be printed if the XtraPrinting Library is available. To show a print preview, use LayoutControl.ShowPrintPreview or LayoutControl.ShowRibbonPrintPreview.

Note

With the XtraPrinting library you’re also able to export the control to various formats (PDF, HTML, etc.).

Example

The following example demonstrates how to print a LayoutControl and show its Print Preivew. The LayoutControl.Print and LayoutControl.ShowPrintPreview methods are called respectively.

csharp
using DevExpress.XtraLayout;
// ...

private void ShowLayoutControlPreview(LayoutControl layout) {
    // Check whether the LayoutControl can be previewed.
    if (!layout.IsPrintingAvailable) {
        MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error");
        return;
    }

    // Open the Preview window.
    layout.ShowPrintPreview();
}

private void PrintLayoutControl(LayoutControl layout) {
    // Check whether the LayoutControl can be printed.
    if (!layout.IsPrintingAvailable) {
        MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error");
        return;
    }

    // Print.
    layout.Print();
}
vb
Imports DevExpress.XtraLayout
' ...

Sub ShowLayoutControlPreview(ByVal layout As LayoutControl)
   ' Check whether the LayoutControl can be previewed.
   If Not layout.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error")
      Return
   End If

   ' Opens the Preview window.
   layout.ShowPrintPreview()
End Sub

Sub PrintLayoutControl(ByVal layout As LayoutControl
   ' Check whether the LayoutControl can be printed.
   If Not layout.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error")
      Return
   End If

   ' Print.
   layout.Print()
End Sub

See Also

IsPrintingAvailable

ShowPrintPreview()

Printing and Export

LayoutControl Class

LayoutControl Members

DevExpress.XtraLayout Namespace