Assign 'StandardPrintController' or a custom 'PrintController' object to the
'PrintDocument' object's 'PrintController' property. By default
'PrintControllerWithStatusDialog' is used.
Thanks Herfried,
I made this code to do the job, it's a combination of several codes I
found. I'm new to dot net...
Greatings,
koen
Public Class myPrinter
Friend TextToBePrinted As String
Private Sub PrintPageHandler(ByVal sender As Object, _
ByVal args As Printing.PrintPageEventArgs)
Dim myFont As New Font("Microsoft San Serif", 10)
args.Graphics.DrawString(TextToBePrinted, _
New Font(myFont, FontStyle.Regular), _
Brushes.Black, 0, 0)
End Sub
Public Sub My_Print(ByVal text As String)
TextToBePrinted = text
Dim m_PrintDocument As New Printing.PrintDocument
Using (m_PrintDocument)
Dim printControl As New Printing.StandardPrintController
m_PrintDocument.PrinterSettings.PrinterName =
"Printername"
AddHandler m_PrintDocument.PrintPage, AddressOf
Me.PrintPageHandler
m_PrintDocument.PrintController = printControl
m_PrintDocument.Print()
RemoveHandler m_PrintDocument.PrintPage, AddressOf
Me.PrintPageHandler
End Using
End Sub
'Create a button on a form
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Dim Print As New myPrinter
Print.My_Print("This is a test" & vbLf & "Without the Status
window")
End Sub