put \\scaps in RTF for small caps - c#

I'm using dynamic RichTextBox control in C# 2.0 and I want to insert "\scaps" in RTF so that if the file is saved programatically and then opened in MS-Word certain text be seen smallcaps.
Can anyone tell me the code as how to insert the tag?

Well, you can access the rich text directly through the Rtf property on the rich text box.

Related

Saving RTF on DataBase and loading it back into WinForms application

I have a Windows Forms Application with a RichTextBox control. I want the user to write rich text on that control (with bold, changes of letter size and all that stuff), save that rich text on database, and then load it again on my Windows Forms application properly formatted.
The way I'm trying to do this, I save on a varchar field in my database the contain of RichTextBox.Rtf property, like this:
string richText = myRichTextBox.Rtf;
Then richText is saved on database exactly as is read on that line. To load the rich text back into winform, code is a little bit more tricky:
//Function that receives a string whit rich text and loads it into richTextBox
private void LoadRTF(string RTF)
{
MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(RTF));
myRichTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
} //LoadRTF
Problem is with this last code, when loading RTF from database is throwing an argument exception. Any idea why this is happening?
Turns out I was just not escaping some characters in SQL query. Now everything seems to work fine.

changing format of RichTextBox without selecting any text

I would like to create a Richtextbox which load a huge file (several pages of text in some format) and based on format it formats the text (let's say it display html).
I found how to change format of text using selection, but that is very slow and resource expensive. Is there a way to append a preformatted text to Rich Text Box? So that I can format each element and then append it.
This might help you if not the answer you are looking for
But RichTextBox.CanPaste Method determines whether you can paste information from the Clipboard in the specified data format. Please see link the for the System.Windows.Forms.DataFormats it will support

How to display RTF text in to tinyMCE editor

I am using tinyMCE editor. I have rtf formatted string in database column which I want to show in the browser editor i.e. tinyMCE. So that, user will edit the text as he wants. But for that I found I need to convert the rtf string in to xml to see it, since my tinyMCE is showing xmls properly. I am able to show the text from rtf string but I misses out the formatting like bold text, red colored text, \n etc. I want to retain all this formatting. How shall I retain the formatting or how shall I display the rtf text with the formatting or how shall I convert rtf text in to xml properly? I want to display rtf text like I am saving it in some rtf file and opening that file in ms word or open office word that way I want to see the format. rtf is Rich Text format.
You should convert your RTF to HTML and use that for TinyMCE, here is a code project article that will get you started :
http://www.codeproject.com/Articles/27431/Writing-Your-Own-RTF-Converter

Finding RTF code associated with selected text in RichTextBox

I am using winform RichTextBox and I wonder if we can find the corresponding rtf code (or at least whereabouts of it) when selecting text?
Use the SelectedRtf property.

c# Write data to an rtf file

I am trying to write data to an RTF file and set certain characters to a different color. I found out how to do it in a box but I can't figure out how to write it to a file.
If by "do it on a box" you mean RichTextBox you can use the RichTextBox.SaveFile() mothod.
Take a look here.

Categories

Resources