The ShowPrintPreview method shows a print preview of the data displayed by the Grid Control's DefaultView (the MainView or the currently maximized detail View). The opened print preview window is built using a Bars UI. To display the Print Preview window with a Ribbon UI, use the ShowRibbonPrintPreview method.
The grid 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 IsPrintingAvailable property.
To print the data without showing a print preview, use Print or PrintDialog.
See Printing Overview to learn more.

Example
The following example demonstrates how to print a Grid Control or show its Print Preview. To do this, you should use either the Print or ShowPrintPreview methods.
Note
The Grid Control can be printed and previewed only if the XtraPrinting Library is available. To verify that printing the Grid is possible, use the IsPrintingAvailable property.
When printing a Grid, the current print settings will be used to represent a Grid. Note that you can access and change these settings via the GridView.OptionsPrint, BandedGridView.OptionsPrint or CardView.OptionsPrint properties.
C# |
using DevExpress.XtraGrid;
private void ShowGridPreview(GridControl grid) {
if (!grid.IsPrintingAvailable) {
MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error");
return;
}
grid.ShowPrintPreview();
}
private void PrintGrid(GridControl grid) {
if (!grid.IsPrintingAvailable) {
MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error");
return;
}
grid.Print();
}
|
VB |
Imports DevExpress.XtraGrid
Sub ShowGridPreview(ByVal grid As GridControl)
If Not grid.IsPrintingAvailable Then
MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error")
Return
End If
grid.ShowPrintPreview()
End Sub
Sub PrintGrid(ByVal grid As GridControl)
If Not grid.IsPrintingAvailable Then
MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error")
Return
End If
grid.Print()
End Sub
|