Articles in this section
Category / Section

How to Print Preview of the WinForms GridControl?

1 min read

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 WinForms 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 


Conclusion

I hope you enjoyed learning about how to Print Preview of the WinForms GridControl.

You can refer to our WinForms Grid feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to create and manipulate data.

For current customers, you can check out our 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 other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied