)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the print preview dialog in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: November 13, 2015 |
Last Revised Date: December 31, 2019
Tags: printing

Customize the print preview dialog

Print preview dialog can be customized by creating a new form like print preview dialog window. In the code sample, the print document GridPrintDoc has been derived from GridPrintDocumentAdv and drawing of the grid will be performed using 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());
    }
}

 

VB

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

 

Screenshot:

Customize the print preview dialog

Samples:

C#: Print Preview

VB: Print Preview

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/printing

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Mukesh Rebari
Aug 08, 2016
sir give me one more day to resolve this issues

thanx
Reply
Neelakandan Kannan [Syncfusion]
Aug 08, 2016
Hi Mukesh,

Can you please let us know what kind of issue that you are having in Print Preview?

Regards,
Neelakandan

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon