• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Printing the contents of a textbox ( sending the text to a printer0

I have a form where after somr caculation are done the information is added to a textBox.  I want to place a button
on this form and when you click it. and it sends the text to the printer. How about doing the same with a listbox.

The text in the textbox is  like:

(100) ...One Hundred
(1,010)... One thousand Ten
(1,000,954)...One Million Nine Hundred Fifty Four
and so on

program converts numbers to text
0
ucla11
Asked:
ucla11
  • 2
1 Solution
 
eozz_2000Commented:
You can use a printDocument to print the things you want in the printPage event of the object with the e.Graphics.DrawString method.
0
 
ucla11Author Commented:
eozz_2000 how would I use this code to print a Richtextbox?
0
 
eozz_2000Commented:
   Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim Lines() As String = Me.RichTextBox1.Lines
        Dim strLine As String
        Dim y As Integer = e.PageBounds.Top
        For Each strLine In Lines
            e.Graphics.DrawString(strLine, New Font("Arial", 10, FontStyle.Regular), Brushes.Black, e.PageBounds.Left, y)
            y += 10
        Next
    End Sub
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now