Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 ca't 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 Form's 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

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...