C# DataGridView Printing
The DataGridView control, designed specifically for Windows Forms, offers a comprehensive solution for efficiently displaying tabular data. This control not only possesses exceptional configurability and extensibility, but it also boasts a wide range of properties, methods, and events that facilitate the customization of its appearance and behavior. Regrettably, the DataGridView lacks a built-in printing functionality, necessitating an alternative approach to accomplish this task.
To overcome this limitation, a practical workaround involves integrating a PrintDocument object into the project and managing the PrintPage event, which is triggered whenever a new page is ready for printing. Within the PrintPage event, a Bitmap Object is created, allowing the DataGridView to be rendered onto it seamlessly. For the successful execution of this C# project, it is imperative to incorporate two buttons—one for loading data and the other for initiating the print command. Additionally, don't forget to include a PrintDocument control on your form to facilitate the printing process.
The following picture shows how to drag PrintDocument Object to your project.Full Source C#