Back to Devexpress

How to: Preview XtraGrid Control

windowsforms-1872-build-an-application-printing-and-exporting-how-to-preview-xtragrid-control.md

latest999 B
Original Source

How to: Preview XtraGrid Control

  • Oct 29, 2020

The following example shows how to preview XtraGrid.

csharp
private void ShowGridPreview(DevExpress.XtraGrid.GridControl grid) {
   // Check whether the Grid Control can be previewed.
   if(!grid.IsPrintingAvailable) {
      MessageBox.Show("The 'DevExpress.XtraPrinting' Library is not found", "Error");
      return;
   }
   // Opens the Preview window.
   grid.ShowPreview();
}
vb
Sub ShowGridPreview(ByVal grid As DevExpress.XtraGrid.GridControl)
   ' Check whether the Grid Control can be previewed.
   If Not grid.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting' Library is not found", "Error")
      Return
   End If
   ' Opens the Preview window.
   grid.ShowPreview()
End Sub

The image below shows a Preview window for a sample grid.