Question Print from rich text box

doomslagen

Member
Joined
Mar 13, 2010
Messages
6
Programming Experience
1-3
I have a rich text box, "RichTextBox1", and a print document, "PrintDocument1". How do I connect the text box with the print document so that the print document is the text of the text box? I have already set up my print dialog, but I just haven't found how to set up the document yet. Please help me.
 

doomslagen

Member
Joined
Mar 13, 2010
Messages
6
Programming Experience
1-3
Re

This doesnt help me at all.

I have already set up all of that. I just need to set up the print document itself to work with the richtextbox. :mad:

Can someone please just give me a working example?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,431
Location
Norway
Programming Experience
10+
Both suggestions are working perfectly. Code samples are also given for both methods. In "plain text" article it says "We could use this class as follows:", in "rich text" article there is downloadable sample application.
 

doomslagen

Member
Joined
Mar 13, 2010
Messages
6
Programming Experience
1-3
I dont understand any of that. I just need to take what is in the box and put it into the printdocument.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,431
Location
Norway
Programming Experience
10+
What could be easier than using these two lines of code?
VB.NET:
Dim MyPrintObject As New TextPrint(RichTextBox1.Text)
MyPrintObject.Print()
The other one is equally simple, all you need is to load the project and press play to see it working. The PrintDocument code for that one includes about 10 lines of code and can be used in your own projects without modification.
 

doomslagen

Member
Joined
Mar 13, 2010
Messages
6
Programming Experience
1-3
thank you very much! I couldnt pick through the code to find that because it was too confusing. That is what I was trying to say!
 
Top Bottom