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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Print Preview the WinForms GridControl?

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

Print preview

The GridPrintDocument class implements the printing logic needed to print multi-page Grids and the object of the GridPrintDocument is associated with the PrintPreviewDialog to display the print preview dialog.

For example, you can print preview the Grid by using the following code.

C#

private void PrintPreview_Click(object sender, EventArgs e)
{
 if (this.gridControl1 != null)
 {
  try
  {
   GridPrintDocument gpd = new GridPrintDocument(this.gridControl1, true);
   PrintPreviewDialog pd = new PrintPreviewDialog();
   pd.Document = gpd;
   pd.ShowDialog();
  }
  catch (Exception ex)
  {
   MessageBox.Show("Error Occured" + ex.Message);
  }
 }
}

 

VB

Private Sub PrintPreview_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
 If Me.gridControl1 IsNot Nothing Then
  Try
   Dim gpd As New GridPrintDocument(Me.gridControl1, True)
   Dim pd As New PrintPreviewDialog()
   pd.Document = gpd
   pd.ShowDialog()
  Catch ex As Exception
   MessageBox.Show("Error Occured" & ex.Message)
  End Try
 End If
End Sub

 

The following screenshot displays the Print preview dialog.

Print preview window is opened

 

Samples:

C#: Print preview

VB: Print preview

 

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