Back to Devexpress

ChartControl.PrintInitialize Event

windowsforms-devexpress-dot-xtracharts-dot-chartcontrol-56a49174.md

latest3.3 KB
Original Source

ChartControl.PrintInitialize Event

Allows you to customize print and export options before the chart is printed or exported.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

csharp
public event ChartPrintInitializeEventHandler PrintInitialize
vb
Public Event PrintInitialize As ChartPrintInitializeEventHandler

Event Data

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

PropertyDescription
LinkGets a PrintableComponentLinkBase object that provides the general functionality to print the Chart Control.
PrintingSystemReturns the Printing System used to create and print a document for the link associated with the Chart Control.

Remarks

You can preview, print and export the chart if the Printing-Exporting library is available and the DevExpress.XtraPrinting.25.2 and DevExpress.Printing.v25.2.Core assemblies are added to the project.

Example

The following code shows how to use the ChartControl.PrintInitialize event to configure the chart’s print options before the chart is previewed.

csharp
using DevExpress.XtraPrinting;
//...
chartControl.PrintInitialize += chartControl_PrintInitialize;

private void chartControl_PrintInitialize(object sender, DevExpress.XtraCharts.ChartPrintInitializeEventArgs e) {            
         PrintingSystemBase printingSystem = e.PrintingSystem as PrintingSystemBase;
         printingSystem.PageSettings.Landscape = true;
 }

// Preview the chart in the landscape orientation.
chartControl.ShowPrintPreview();
vb
Imports DevExpress.XtraPrinting
'...
chartControl.PrintInitialize = (chartControl.PrintInitialize + chartControl_PrintInitialize)

Private Sub chartControl_PrintInitialize(ByVal sender As Object, ByVal e As DevExpress.XtraCharts.ChartPrintInitializeEventArgs)
        Dim printingSystem As PrintingSystemBase = CType(e.PrintingSystem,PrintingSystemBase)
        printingSystem.PageSettings.Landscape = true
End Sub

' Preview the chart in the landscape orientation.
chartControl.ShowPrintPreview

See Also

ChartControl Class

ChartControl Members

DevExpress.XtraCharts Namespace