How to customize the print preview dialog in WinForms GridGroupingControl?
Customize the print preview dialog
The print preview dialog can be customized by creating a new form, like the print preview dialog window in WinForms GridGroupingControl. In the code sample, the print document GridPrintDoc has been derived from GridPrintDocumentAdv, and the grid will be drawn using the DrawGrid method.
C#
rectToPrintGrid = new Rectangle(eventArgs.MarginBounds.Left, intOffset, intGridWidth, intGridHeight);
//draw the grid in print preview pages
_grid.DrawGrid(eventArgs.Graphics, rectToPrintGrid, false, false);
private void PrintPreview_Click(object sender, EventArgs e)
{
try
{
//GridPrintDoc is derived from the Syncfusion.GridHelperClasses.GridPrintDocumentAdv
GridPrintDoc pd = new GridPrintDoc(this.gridGroupingControl1.TableControl);
frm = new PreviewDialog(this.gridGroupingControl1); //PreviewDialog is derived from the Form
frm.document = pd;
frm.ShowDialog();
if (frm.PageSetting == null)
{
return;
}
}
catch (Exception ex)
{
MessageBox.Show("Error while print preview" + ex.ToString());
}
}rectToPrintGrid = New Rectangle(eventArgs.MarginBounds.Left, intOffset, intGridWidth, intGridHeight)
'draw the grid in print preview pages
_grid.DrawGrid(eventArgs.Graphics, rectToPrintGrid, False, False)
Private Sub PrintPreview_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PrintPreview.Click
Try
'GridPrintDoc is derived from the Syncfusion.GridHelperClasses.GridPrintDocumentAdv
Dim pd As GridPrintDoc = Nothing
pd = New GridPrintDoc(Me.gridGroupingControl1.TableControl)
'PreviewDialog is derived from the Form
frm = New PreviewDialog(Me.gridGroupingControl1)
frm.grouping_grid = Me.gridGroupingControl1
frm.document = pd
frm.ShowDialog()
If frm.PageSetting Is Nothing Then
Return
End If
Catch ex As Exception
MessageBox.Show("Error while print preview" & ex.ToString())
End Try
End Sub
Samples:
C#: Print Preview
VB: Print Preview
Reference Link: Printing
Conclusion
I hope you enjoyed learning about how to customize the
print preview dialog in GridGroupingControl.
You can refer to our WinForms GridGroupingControl feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!