Printing using PrintDocument

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

Hello,
I'm trying to print a dataGrid using PrintDocument control. My datagrid has
about 23 columns so it is fairly wide. When I use the PrintControl, it
prints only the part of the dataGrid that is visible on screen. I tried
using PrintPreviewDialog too but it still only shows just what is visible in
the dialog that houses the dataGrid. I want to get all the datagrid printed.
Maybe wrapping it would be the only way to print all of it...but I don't
know how to grab all the datagrid to the right, the part off screen. Anyone
know how...
Thanks
 
Randy, what are you doing in your Print Events? Could you post that code so
we can see what is going on?
 
Greg,
Sure, it is pretty simple (see below). I have the printDocument1 and the
bPrint button click event and then the printDocument1 printpage event...
Thanks

PrintDocument printDocument1 = new PrintDocument();

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(dataGrid1, myPaintArgs);
}

private void bPrint_Click(object sender, System.EventArgs e)
{
printDocument1.Print();
}
 
Back
Top