Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public partial class Sample : Form
  2. {
  3.  
  4. public Sample()
  5. {
  6. InitializeComponent();
  7. }
  8.  
  9. private void Form1_Load(object sender, EventArgs e)
  10. {
  11.  
  12.  
  13. private void myPrintDocument1_PrintPage(System.Object sender,PrintPageEventArgs e)
  14. {
  15. Bitmap myBitmap2 = new Bitmap(this.Width, this.Height);
  16. this.DrawToBitmap(myBitmap2, new Rectangle(0, 0, this.Width, this.Height));
  17. e.Graphics.DrawImage(myBitmap2,0,0);
  18. myBitmap2.Dispose();
  19. }
  20.  
  21.  
  22. private void buttPrint_Click(object sender, EventArgs e)
  23. {
  24.  
  25. PrintDocument myPrintDocument2 = new PrintDocument();
  26. PrintDialog myPrinDialog2 = new PrintDialog();
  27. myPrintDocument2.PrintPage += new PrintPageEventHandler(myPrintDocument1_PrintPage);
  28. myPrinDialog2.Document = myPrintDocument2;
  29.  
  30. if (myPrinDialog2.ShowDialog() == DialogResult.OK)
  31. {
  32. myPrintDocument2.Print();
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement