Help with printing from form

chopps

New member
Joined
Feb 13, 2011
Messages
4
Programming Experience
Beginner
Hello All,I have an assignment where I'm supposed to create a simple text editor but I'm having some issues with the print function. I thought I could print by using the following:

**************************************

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Dim print As PrintDialog = New PrintDialog()
btnPrint.Enabled = print.ShowDialog()
If print.ShowDialog() = Windows.Forms.DialogResult.OK Then
End If
End Sub

**************************************
It does open the print dialog box but when I select OK it simply redisplays the print dialog box. I press OK again and the dialog box disappears but nothing prints. Please keep in mind I am totally an amateur so any hints or tips on how I can achieve this would be very helpful.
 
The key component of System.Drawing.Printing namespace is the PrintDocument class, where you handle PrintPage event to provide what is to be printed.
If you just want a print-out of the form as it is displayed on screen try the PrintForm component.
 
Thanks for the reply. I didn't know there was an add-on to make it easier to print in vb 6.0. Worked like a charm. THanks a lot.
 
PrintForm was included as standard component from VB 2008, previously it has been available as addin from the Visual Basic PowerPacks, which is why it is added to that section in toolbox instead of the Printing section.
 
Back
Top