Printing in Windows Forms Chart

7 Jan 20252 minutes to read

The chart provides a PrintDocument that can be sent to the .NET PrintPreviewDialog to get a preview of the chart that gets printed. Here is some code that shows how this is done.

PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();

//Customizing the icon of print preview dialog

(printPreviewDialog1 as Form).Icon = new Icon(@"..\..\App.ico");

printPreviewDialog1.Document = this.chartControl1.PrintDocument;

printPreviewDialog1.ShowDialog();
Me.printPreviewDialog1 = New System.Windows.Forms.PrintPreviewDialog

'Customizing the icon of print preview dialog

CType(printPreviewDialog1,Form).Icon = New Icon("..\..\App.ico")

printPreviewDialog1.Document = Me.chartControl1.PrintDocument

printPreviewDialog1.ShowDialog()

Chart Print

Printing

Print a chart control using the PrintDocument exposed by the chart control as follows:

this.chartControl1.PrintDocument.Print();
Me.chartControl1.PrintDocument.Print()

You can also specify if you want to print the chart in Color or GrayScale using PrintColorMode property.

Chart control Property Description

PrintColorMode

Indicates the color mode during printing. Possible Values:
  • Color - Always Print in Color.
  • GrayScale - Always Print using GrayScale.
  • CheckPrinter - If printer allows color print in color, otherwise use gray scale (default setting).
this.chartControl1.PrintColorMode = ChartPrintColorMode.GrayScale;
Me.chartControl1.PrintColorMode = ChartPrintColorMode.GrayScale

Automatic GrayScale Handling

Setting GrayScale print mode for the chart lets you print the chart in a gray scale and when multiple series are printed in this case, chart data points are automatically rendered with a patterned brush to differentiate the different series as shown in the image below.

Chart Print

A sample illustrating the printing features is available in the below location.

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Print\Chart Print

Displaying ToolBar while printing

ShowToolBar property should be set to true to display a toolbar in the Chart. You can show or hide the toolbar while printing a Chart using PrintToolBar property.

chartControl1.ShowToolbar = true;

chartControl1.PrintDocument.PrintToolBar = true;
chartControl1.ShowToolbar = True

chartControl1.PrintDocument.PrintToolBar = True