1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
   |  
Option Explicit On
Public Class Form1
 Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Me.PrintPreviewControl1.Zoom = 0.6
  Me.PrintPreviewControl1.Rows = 1
  Dim PageSetupDialog As New PageSetupDialog()
  PageSetupDialog.Document = PrintDocument1
  PageSetupDialog.PageSettings.Landscape = True 
  Me.PrintPreviewControl1.Document = Me.PrintDocument1
 End Sub
 
 Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  Dim PageSetupDialog As New PageSetupDialog()
  PageSetupDialog.Document = PrintDocument1
  PageSetupDialog.PageSettings.Landscape = True 
  Me.PrintDocument1.Print()
 End Sub
 
 Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
  Dim bmp As New Bitmap(Me.Width, Me.Height, Imaging.PixelFormat.Format32bppArgb)
  Me.DrawToBitmap(bmp, New Rectangle(0, 0, Me.Width, Me.Height))
  e.Graphics.DrawImage(bmp, 10, 10)
 End Sub
End Class  | 
Partager