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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to print a grid with the WinForm screen in WinForms GridControl?

Platform: WinForms |
Control: GridControl
Tags: printing

Handle the PrintPage event

You can handle the PrintPage event during printing or print preview and the page is drawn by the Graphic object of PrintPageEventArgs as follows.


void Document_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    //set the image
    Bitmap bt = new Bitmap(this.Width, this.Height);
    //set the renderering to the specified bitmap
    this.DrawToBitmap(bt, new Rectangle(0, 0, this.Width, this.Height));
    //draw the image in the given location.
    e.Graphics.DrawImage(bt, new Point(0, 0));
private void button1_Click_1(object sender, EventArgs e)
    PrintPreviewDialog ppd = new PrintPreviewDialog();
    ppd.Document = new System.Drawing.Printing.PrintDocument();
    ppd.Document.PrintPage += Document_PrintPage;
    //show the PrintPreviewDialog


Private Sub Document_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
 'set the image
 Dim bt As New Bitmap(Me.Width, Me.Height)
 'set the renderering to the specified bitmap
 Me.DrawToBitmap(bt, New Rectangle(0, 0, Me.Width, Me.Height))
 'draw the image in the given location.
 e.Graphics.DrawImage(bt, New Point(0, 0))
End Sub
Private Sub button1_Click_1(ByVal sender As Object, ByVal e As EventArgs)
 Dim ppd As New PrintPreviewDialog()
 ppd.Document = New System.Drawing.Printing.PrintDocument()
 AddHandler ppd.Document.PrintPage, AddressOf Document_PrintPage
 'show the PrintPreviewDialog
End Sub

After applying the properties, the Grid is displayed as follows.

Print preview of the grid

Figure 1: Print Preview of the Windows Form Grid


C#: PrintPreview_winform

VB: PrintPreview_winform

Reference link: https://help.syncfusion.com/windowsforms/grid-control/printing

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

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