Click here to Skip to main content
14,872,121 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:

I want to print data grid view. I have no idea how to do it.

Please some body help me.

Your best bet is always to format and print the data from your data source, not trying to print a control.
Hej Mate

I hope that I understand your needs on the printing concern. I have found a link which I hope will be helpful for your task:

If this link is not functioning, try to maintain the code up on your requirement.
private DataGridViewPrint PrintGrid;
private void btnPrint_Click(object sender, System.EventArgs e)
frmPrint fpr = new frmPrint();
fpr.Title = DataGridView1.CaptionText;
if (fpr.Result > 0)
PrintGrid = new DataGridViewPrint(printDocument1, DataGridView1, fpr.bBlackWhite);
PrintGrid.PrintTitle = fpr.bTitle;
PrintGrid.Title = fpr.Title;
if (fpr.Result == 1) // Print
if (printDialog1.ShowDialog() == DialogResult.OK)
// The Print method prints the DataGridView without using a print dialog.
// Use a PrintDialog when you want to offer the user the ability to choose print settings.
else if (fpr.Result == 2) // Page setup
else if (fpr.Result == 3) // Preview
printPreviewDialog1.Icon = fpr.Icon;
// Specify the output to print by handling the PrintPage event 
// and by using the Graphics included in the PrintPageEventArgs.
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
// Print method of DataGridViewPrint class starts the custom DataGridView's printing process.
e.HasMorePages = PrintGrid.Print(e.Graphics);

good luck
In the past, I remember using a code that would transform a DataGridView into a HTML file that could then be embedded in WebBrowser control and printed. It worked flawlessy, though I can't find it anymore. Instead, try using this Another DataGridView Printer[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900