Skip to main content

BaseView.PrintInitialize Event

Allows you to customize general print/export settings when the View is about to be printed/exported.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v23.2.dll

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

Declaration

[DXCategory("Data")]
public event PrintInitializeEventHandler PrintInitialize

Event Data

The PrintInitialize event's data class is PrintInitializeEventArgs. The following properties provide information specific to this event:

Property Description
Link Gets a PrintableComponentLinkBase object that provides functionality to print the Grid Control.
PrintingSystem Gets a IPrintingSystem object that contains information on the print document.

Remarks

You can use the PrintInitialize event to customize general print/export settings. For instance, you can customize the paper orientation and margins via the event’s PrintInitializeEventArgs.PrintingSystem parameter (cast this parameter to the PrintingSystemBase type).

The Grid Control can be previewed, printed and exported if the XtraPrinting Library is available. To check if this library is available, use the GridControl.IsPrintingAvailable property. See Printing Overview to learn more.

Example

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.

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();
See Also