)
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 print the grid in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 17, 2019
Tags: printing

Print the grid

The GridPrintDocument class implements the printing logic needed to print multi-page Grids. For example, here is a button click event handler that shows you how to use this GridPrintDocument class.

 

C#

private void Print_Click(object sender, EventArgs e)
{
 if (gridControl1 != null)
 {
  try
  {
   GridPrintDocument gpd = new GridPrintDocument(this.gridControl1);
   PrintDialog pd = new PrintDialog();
   pd.Document = gpd;
   pd.AllowSelection = true;
   pd.AllowSomePages = true;
   DialogResult result = pd.ShowDialog();
   if (result == DialogResult.OK)
   {
    gpd.Print();
   }
  }
  catch (Exception ex)
  {
   MessageBox.Show("Error Occured" + ex.Message);
  }
 }
}

 

VB

Private Sub Print_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
 If gridControl1 IsNot Nothing Then
  Try
   Dim gpd As New GridPrintDocument(Me.gridControl1)
   Dim pd As New PrintDialog()
   pd.Document = gpd
   pd.AllowSelection = True
   pd.AllowSomePages = True
   Dim result As DialogResult = pd.ShowDialog()
   If result = System.Windows.Forms.DialogResult.OK Then
    gpd.Print()
   End If
  Catch ex As Exception
   MessageBox.Show("Error Occured" & ex.Message)
  End Try
 End If
End Sub

 

Samples:

C#: Print the grid

VB: Print the grid

 

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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
Live Chat Icon