2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
PrintingTo customize the specific pages for printing, you can use the PrintPage event. This event can be triggered for each page during printing. You can also use BeginPrint event. This event is triggered once printing is performed. The default value of the PrintRange is All. For printing the specific pages, it should be changed to PrintRange.SomePages through BeginPrint event. In the following code example, the first and second pages are selected for printing. C# Syncfusion.GridHelperClasses.GridPrintDocumentAdv pd = new Syncfusion.GridHelperClasses.GridPrintDocumentAdv(this.gridControl1); //Triggers the BeginPrint event pd.BeginPrint += new System.Drawing.Printing.PrintEventHandler(pd_BeginPrint); //Triggers the PrintPage event pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage); //Handles the BeginPrint event private void pd_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { ((GridPrintDocumentAdv)sender).PrinterSettings.PrintRange = PrintRange.SomePages; //Prints 1st and 2nd page ((GridPrintDocumentAdv)sender).PrinterSettings.FromPage = 1; ((GridPrintDocumentAdv)sender).PrinterSettings.ToPage = 2; } //Handles the PrintPage event private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //Customizes your code here Console.WriteLine("The page is printing..."); }
VB Private pd As New Syncfusion.GridHelperClasses.GridPrintDocumentAdv(Me.gridControl1) 'Triggers the BeginPrint event Private pd.BeginPrint += New System.Drawing.Printing.PrintEventHandler(AddressOf pd_BeginPrint) 'Triggers the PrintPage event Private pd.PrintPage += New System.Drawing.Printing.PrintPageEventHandler(AddressOf pd_PrintPage) 'Handles the BeginPrint event Private Sub pd_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) CType(sender, GridPrintDocumentAdv).PrinterSettings.PrintRange = PrintRange.SomePages 'Prints 1st and 2nd page CType(sender, GridPrintDocumentAdv).PrinterSettings.FromPage = 1 CType(sender, GridPrintDocumentAdv).PrinterSettings.ToPage = 2 End Sub 'Handles the PrintPage event Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) 'Customizes your code here Console.WriteLine("The page is printing...") End Sub
Note: In the above example, particular pages are printed when you press print button. The Range of pages can be given by using the FromPage and ToPage properties of the PrinterSettings.
Samples: C#: Somepages print-C# Reference link: https://help.syncfusion.com/windowsforms/grid-control/printing |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.