Advertisement
Advertisement
| 07.04.2008 at 12:04AM PDT, ID: 23538875 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: |
public void GetPrintArea(Panel pnl)
{
Rectangle rect = new Rectangle(pnl.Location.X, pnl.Location.Y, pnl.Width ,pnl.Height);
Graphics myGraphics = pnl.CreateGraphics();
Size s = pnl.PreferredSize;
MemoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(MemoryImage);
memoryGraphics.CopyFromScreen(pnl.Location.X,pnl.Location.Y, 0, 0, s,CopyPixelOperation.SourceCopy);
}
void printdoc1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(MemoryImage, 0, 0);
}
#endregion
public void Print(Panel pnl)
{
pannel = pnl;
GetPrintArea(pnl);
previewdlg.Document = printdoc1;
previewdlg.ShowDialog();
}
|