HOW TO PRINT A DATAGRID VIEW 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:
  1. private void button2_Click(object sender, EventArgs e)
  2.         {
  3.             printDocument1.Print();    
  4.         }
  5. private void printDocument1_PrintPage(object sender,
  6.                   System.Drawing.Printing.PrintPageEventArgs e)
  7.         {
  8.             PaintEventArgs myPaintArgs = new PaintEventArgs(e.Graphics,
  9.                                  new Rectangle(new Point(0, 0), this.Size));
  10.             this.InvokePaint(dataGridView1, myPaintArgs);
  11.         }

Comments

Popular posts from this blog

How to prepare your PC for the Windows 10 upgrade Source: WC

Salesforce LWC - Mass Approval Component

Top 5 Japanese Anime (Cartoons)