Hello,
VB Newbie question
I have a one form VB.NET project. When the user clicks a print button I wish the printer dialog to appear and the form contents print when "Print" is selected.
Doesn t seem so hard.
Bt I cat get this form contents to print! I found this niffty bit of code that opens the print dialog but even when I hard code a text string to print nothing appear but a blank page.
The code I used appear below...
I highlight the print portion of the code using =====
Is there just a couple of linse of code that could make this work?
Any suggesstions wold be geratly appreciated.
Private Sub mnuPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrint.Click
add from sample also see above
The PrintDialog allows the user to select the printer that they want to print
to, as well as other printing options.
Dim dialog As New PrintDialog()
dialog.Document = pdoc
If dialog.ShowDialog = DialogResult.OK Then
pdoc.Print()
End If
End Sub
Handles the Forms Load event, initializing the TextBox with some text
for printing.
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
==========printer code start here ==========
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RichTextBox1.Text = "Even this hard coded text will not print"
Dim prnForm As PrintDocument owork
prnForm.myDocumentForm1() owork
printer.print("text") owork
==========end printer code ============
End Sub
VB Newbie question
I have a one form VB.NET project. When the user clicks a print button I wish the printer dialog to appear and the form contents print when "Print" is selected.
Doesn t seem so hard.
Bt I cat get this form contents to print! I found this niffty bit of code that opens the print dialog but even when I hard code a text string to print nothing appear but a blank page.
The code I used appear below...
I highlight the print portion of the code using =====
Is there just a couple of linse of code that could make this work?
Any suggesstions wold be geratly appreciated.
Private Sub mnuPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrint.Click
add from sample also see above
The PrintDialog allows the user to select the printer that they want to print
to, as well as other printing options.
Dim dialog As New PrintDialog()
dialog.Document = pdoc
If dialog.ShowDialog = DialogResult.OK Then
pdoc.Print()
End If
End Sub
Handles the Forms Load event, initializing the TextBox with some text
for printing.
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
==========printer code start here ==========
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RichTextBox1.Text = "Even this hard coded text will not print"
Dim prnForm As PrintDocument owork
prnForm.myDocumentForm1() owork
printer.print("text") owork
==========end printer code ============
End Sub