Solved

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

Posted on 2004-10-14
3
198 Views
Last Modified: 2010-04-23
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
Comment
Question by:ucla11
  • 2
3 Comments
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12313205
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
 

Author Comment

by:ucla11
ID: 12315341
eozz_2000 how would I use this code to print a Richtextbox?
0
 
LVL 4

Accepted Solution

by:
eozz_2000 earned 250 total points
ID: 12315805
   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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now