windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-d4b1b58f.md
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.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("Data")]
public event PrintInitializeEventHandler PrintInitialize
<DXCategory("Data")>
Public Event PrintInitialize As PrintInitializeEventHandler
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. |
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.
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();
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()
See Also