Private Sub buttonPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim printDialog1 As PrintDialog = New PrintDialog
printDialog1.Document = printDocument1
Dim result As DialogResult = printDialog1.ShowDialog
If (result = DialogResult.OK) Then
printDocument1.Print()
End If
End Sub
' Callback from PrintDocument component to
' do the actual printing
Private Sub pd_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles pd.PrintPage
e.Graphics.DrawImage(formImage, 100, 100)
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' create an instance of the PrintDocument component
pd = New Printing.PrintDocument
Me.StartPosition = FormStartPosition.CenterScreen
End Sub
Private Sub btnPrintForm_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles btnPrintForm.Click
' initiate the printdocument component
GetFormImage()
pd.Print()
End Sub