How to print DataGridView in C#

This example demonstrate how we can print Datagridview control in c#. This example requires a button control named Button1, one datagridview control named datagridview1 and one Printdocument component named printdocument1.

and try this code:

private void button2_Click(object sender, EventArgs e)
private void printDocument1_PrintPage(object sender, 
                  System.Drawing.Printing.PrintPageEventArgs e)
            PaintEventArgs myPaintArgs = new PaintEventArgs(e.Graphics,
                                 new Rectangle(new Point(0, 0), this.Size));
            this.InvokePaint(dataGridView1, myPaintArgs);

3 thoughts on “How to print DataGridView in C#”

  1. This article is something new to me.Its always good to come to know about new things.this article is a good one.thanks for sharing it. 

  2. I have one problem that i want to print all the data inside the datagridview the code above just prints the screen not tha whole data kindly tell me how to print whole data.

Comments are closed.