Back to Devexpress

VGridControlBase.ShowPrintPreview() Method

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-960da046.md

latest3.8 KB
Original Source

VGridControlBase.ShowPrintPreview() Method

Opens the Print Preview window with a Bars UI.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
public void ShowPrintPreview()
vb
Public Sub ShowPrintPreview

Remarks

The Print Preview window displays the control’s data as it will appear when it is printed. The control can be previewed and printed if the XtraPrinting Library is available. To check if printing and previewing the grid control is allowed, use the VGridControlBase.IsPrintingAvailable property.

To display the Print Preview window with a Ribbon UI, use the VGridControlBase.ShowRibbonPrintPreview method.

Example

The following example demonstrates how to print a Vertical Grid or show its Print Preivew. To do this, you should use either the VGridControlBase.Print or VGridControlBase.ShowPrintPreview methods.

Note

The Vertical Grid can be printed and previewed only if the XtraPrinting Library is available. To verify that printing the Vertical Grid is possible, use the VGridControlBase.IsPrintingAvailable property.

csharp
using DevExpress.XtraVerticalGrid;
// ...

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

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

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

    // Print.
    vGrid.Print();
}
vb
Imports DevExpress.XtraVerticalGrid
' ...

Sub ShowVerticalGridPreview(ByVal vGrid As VGridControl)
   ' Check whether the Vertical Grid can be previewed.
   If Not vGrid.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error")
      Return
   End If

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

Sub PrintVerticalGrid(ByVal vGrid As VGridControl)
   ' Check whether the Vertical Grid can be printed.
   If Not vGrid.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error")
      Return
   End If

   ' Print.
   vGrid.Print()
End Sub

See Also

Print()

IsPrintingAvailable

ShowRibbonPrintPreview()

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace