Printing in VB.NET

Skip Navigation LinksWelcome to Irocon > Blog > 2003 > November, 2003 > November 14, 2003 > Printing in VB.NET

Printing in VB.NET

By Mike Gold 06/25/2003
Download

Using components is the difference between writing an application in one week vs. an application in a few hours. Printing is all carried out through components included in the toolbox. The main component that talks to the printer is the PrintDocument component. To use this component, just call the Print function and intercept the PrintPage event. Below are the routines that do this:


Protected Sub PrintFile_Click(sender As Object, e As System.EventArgs)
printDialog1.Document = ThePrintDocument
Dim strText As String = Me.richTextBox1.Text
myReader = New StringReader(strText)
If printDialog1.ShowDialog() = DialogResult.OK Then
Me.ThePrintDocument.Print()
End If
End Sub 'PrintFile_Click

More of this article at vbdotnetheaven

Last Updated:Thursday, September 02, 2010By:alferoSource#

Would you like to comment?

Sign in with your OpenID. If you do not know what OpenID is, find out.