This is a migrated thread and some comments may be shown as answers.

Single textbox with "rtf" and "txt" properties

1 Answer 56 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
Larry Brindise
Top achievements
Rank 1
Larry Brindise asked on 23 Sep 2011, 02:16 PM
Is it possible/feasible to have a single multi-line textbox that has two properties:  1.  simple text format (like notepad), and 2. a rich text editor (not HTML format but RTF format).  When the user edits the contents of the multi-line textbox and uses ribbon options, at any time, I need to obtain the ".text" property and get the literal text without all the RTF markup, and if I simultaneously obtain the ".rtf" property, then I get all the text with the embedded rtf format.
I am not an expert in this area, so perhaps my expectation is beyond reality.  However, I am extending a vb6-COM based application with a "com-interop" call out to my .NET library using Telerik controls.  This vb6-COM based application contains a control that functions exactly as above, and I want to reproduce that in my .NET application extension so that I can allow editing of those memos (they are stored in sql as varchar(max)); each of those memo fields in the application database contain two fields "mymemofieldRTF" and "mymemofieldTEXT", and when a user edits one of those memo fields in the vb6-COM based app, the app updates both the "...RTF" and "...TEXT" fields in the database.  When I view the "...RTF" field in the database, it starts with something that looks like:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}} \viewkind4\uc1\pard\f0\fs17

The "...TEXT" version has only raw text as you might find if you edited simply in notepad.

I want to mimic this process in my app, and so I am hoping the WinForm RichTextBox will support this or allow me to extend the class with some relatively simple settings or overrides.
Thanks!
Larry Brindise

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 29 Sep 2011, 01:51 PM
Hi Larry,

I apologize for the late reply.

Yes, you can get the plain text from a RadRichTextBox control by using the TxtFormatProvider class. Here is an example:
using Telerik.WinControls.RichTextBox.FormatProviders.Txt;
 
TxtFormatProvider txt = new TxtFormatProvider();
string text = txt.Export(radRichTextBox1.Document);

I hope it helps.
 
Regards,
Jack
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
Larry Brindise
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or