Click here to Skip to main content
15,885,309 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 http://support.microsoft.com/kb/812425[^] 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 :
Jayanta
Posted

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

Quote:
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#):

http://support.microsoft.com/kb/146022[^]

I hope this will help to you.
 
Share this answer
 
Comments
JayantaChatterjee 28-Sep-13 22:26pm    
Sir, I can't convert this VB6 code into C#.net, there is lots of complexity.... :-(
can you provide it in C# or VB.NET ??
Please....
Sampath Lokuge 29-Sep-13 1:08am    
You can be easily done by using below mentioned converter.Try that.
http://www.developerfusion.com/tools/convert/vb-to-csharp/
Sampath Lokuge 29-Sep-13 1:19am    
http://social.msdn.microsoft.com/Forums/en-US/ea9dd08e-78fd-45ef-8858-38d38ed3a676/converting-vb6-to-c
Sampath Lokuge 29-Sep-13 1:20am    
http://www.codeproject.com/Articles/262950/CodeConverter
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??
[EDIT]
Jayanta Chatterjee asked:
Sir, I download "ILSpy version 2.1.0.1603", 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[^].

—SA
 
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