Click here to Skip to main content
15,615,280 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I want to print RichTextBox Text with same text formatted(font size,color & bold) in RichTextBox which change by user, and I print that(RTB formatted text) with printDocument control, like using Graphic.drawString method ...

I try this :-
e.Graphics.DrawString(RTB1.Text, RTB1.Font, Brushes.Black, new RectangleF(50, 500, RTB1.Width, RTB1.Height));

but its shows in default font of RTB...

I searched, and find[^] this link, here creating a print method of a RTB,but problem is, I want to print RTB text with some other information which provided by(user) other controls text...

So, is it possible to print RichTextBox text with same text-format??
if its not, then tell me the others way to do that????

Thanks in advanced..

Regards :

You have to set up a RichTextBox with a WYSIWYG (What You See Is What You Get) display.

The SelPrint method of the RichTextBox control does not allow a programmer to set the position of the output on the printer. In addition, the RichTextBox control does not provide a method for displaying its contents as they would show up on the printer. This article explains how to set up a RichTextBox with a WYSIWYG (What You See Is What You Get) display and then how to print it.

For more info (this is vb article, but you can easily convert it to C#):[^]

I hope this will help to you.
Share this answer
JayantaChatterjee 28-Sep-13 22:26pm    
Sir, I can't convert this VB6 code into, there is lots of complexity.... :-(
can you provide it in C# or VB.NET ??
Sampath Lokuge 29-Sep-13 1:08am    
You can be easily done by using below mentioned converter.Try that.
Sampath Lokuge 29-Sep-13 1:19am
Sampath Lokuge 29-Sep-13 1:20am
JayantaChatterjee 30-Sep-13 3:21am    
Sir, Thanks for help..
I converted the whole project into C# application.
the VB6 to C# converter doesn't convert this and so many, I solve some of them but I stuck here...
I got an error: couldn't convert "AxRichTextLib.AxRichTextBox" to "RichTextBox1" in C# application.
How to convert it??
Jayanta Chatterjee asked:
Sir, I download "ILSpy version", but i couldn't understand how to convert the VB6 project into C#… <…> can you be more elaborate please???All you need is to look at the application with more attention.
You just needed to pay a bit more attention while trying to use this product.

I explained how to do the translation using ILSpy in my past answer in detail: COde Line Interpretatio of C# to VB.NET[^].

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900