Imports System.Drawing.Printing
Public Class Form2
Private PrintPageSettings As New PageSettings
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim PrintDoc As New PrintDocument
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
PrintDoc.Print()
Catch ex As Exception
MessageBox.Show("Sorry-- there is a problem printing", ex.ToString)
End Try
End Sub
Private Sub PrintText(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
' Private printpagesettings As New PageSettings
ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 120, 120)
ev.HasMorePages = True
ev.Graphics.DrawString("def abc", New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub
End Class
|