Back to Devexpress

How to: Customize Print Settings When Printing GridControl

windowsforms-11543-controls-and-libraries-data-grid-examples-export-and-printing-how-to-customize-print-settings-when-printing-gridcontrol.md

latest1.3 KB
Original Source

How to: Customize Print Settings When Printing GridControl

  • Nov 13, 2018

This example shows how to set the paper orientation to Landscape when printing Grid Control data. To customize print settings, the BaseView.PrintInitialize event is handled. The Landscape option is accessed via the PrintingSystem.PageSettings property.

csharp
using DevExpress.XtraPrinting;

private void gridView1_PrintInitialize(object sender, DevExpress.XtraGrid.Views.Base.PrintInitializeEventArgs e) {
    PrintingSystemBase pb = e.PrintingSystem as PrintingSystemBase;
    pb.PageSettings.Landscape = true;
}

//Show a print preview to test the Landscape paper orientation
gridView1.ShowPrintPreview();
vb
Imports DevExpress.XtraPrinting

Private Sub GridView1_PrintInitialize(sender As System.Object, _
            e As DevExpress.XtraGrid.Views.Base.PrintInitializeEventArgs) _
            Handles GridView1.PrintInitialize
    Dim pb As PrintingSystemBase = CType(e.PrintingSystem, PrintingSystemBase)
    pb.PageSettings.Landscape = True
End Sub

'Show a print preview to test the Landscape paper orientation
GridView1.ShowPrintPreview()