Printing in Windows Forms Pivot Grid
28 Apr 20212 minutes to read
Pivot grid provides support for printing that allows users to print the contents of pivot grid on paper and it also provides support to preview the contents before printing. This support is used to print the pivot grid control in both landscape and portrait views.
The “Syncfusion.GridHelperClasses.Windows” reference needs to be added to the application to achieve this support. The PivotGridPrintDocumentAdv class helps to print the pivot grid content on paper.
Refer to the below code sample to print the pivot grid control.
PivotGridPrintDocumentAdv pivotGridPrintDocumentAdv = new PivotGridPrintDocumentAdv(this.pivotGridControl1);
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
printPreviewDialog.Document = pivotGridPrintDocumentAdv;
printPreviewDialog.ShowDialog();
Dim pivotGridPrintDocumentAdv As New PivotGridPrintDocumentAdv(Me.pivotGridControl1)
Dim printPreviewDialog As New PrintPreviewDialog()
printPreviewDialog.Document = pivotGridPrintDocumentAdv
printPreviewDialog.ShowDialog()
Adding header and footer
Headers and footers can also be added to the printed document by using the HeaderPrintStyleInfo and FooterPrintStyleInfo properties.
Refer to the below code sample to add header and footer while printing the pivot grid control.
PivotGridPrintDocumentAdv pivotGridPrintDocumentAdv = new PivotGridPrintDocumentAdv(this.pivotGridControl1);
pivotGridPrintDocumentAdv.HeaderHeight = 80;
pivotGridPrintDocumentAdv.FooterHeight = 80;
pivotGridPrintDocumentAdv.HeaderPrintStyleInfo.Text = "Pivot Grid";
pivotGridPrintDocumentAdv.HeaderPrintStyleInfo.Font.Size = 14;
pivotGridPrintDocumentAdv.FooterPrintStyleInfo.Text = "Syncfusion";
pivotGridPrintDocumentAdv.FooterPrintStyleInfo.Font.Size = 14;
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
printPreviewDialog.Document = pivotGridPrintDocumentAdv;
printPreviewDialog.ShowDialog();
Dim pivotGridPrintDocumentAdv As New PivotGridPrintDocumentAdv(Me.pivotGridControl1)
pivotGridPrintDocumentAdv.HeaderHeight = 80
pivotGridPrintDocumentAdv.FooterHeight = 80
pivotGridPrintDocumentAdv.HeaderPrintStyleInfo.Text = "Pivot Grid"
pivotGridPrintDocumentAdv.HeaderPrintStyleInfo.Font.Size = 14
pivotGridPrintDocumentAdv.FooterPrintStyleInfo.Text = "Syncfusion"
pivotGridPrintDocumentAdv.FooterPrintStyleInfo.Font.Size = 14
Dim printPreviewDialog As New PrintPreviewDialog()
printPreviewDialog.Document = pivotGridPrintDocumentAdv
printPreviewDialog.ShowDialog()
Events
- The DrawGridPrintHeader event occurs while previewing the pivot grid control. This event helps to customize the default appearance of header added in the printed document.
- The DrawGridPrintFooter event occurs while previewing the pivot grid control. This event helps to customize the default appearance of footer added in the printed document.
A demo sample is available in the following location.
<Installed Drive>\Users\Public\Documents\Syncfusion\Windows\<Version Number>\PivotGrid.Windows\Samples\Printing\Printing Demo