Single textbox with "rtf" and "txt" properties

2 posts, 0 answers
  1. Larry Brindise
    Larry Brindise  avatar
    5 posts
    Member since:
    Jun 2010

    Posted 23 Sep 2011 Link to this post

    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.
    Larry Brindise
  2. Jack
    Jack avatar
    2333 posts

    Posted 29 Sep 2011 Link to this post

    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.
    the Telerik team

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

Back to Top