Add RichTextBox to PropertyGird

4 posts, 0 answers
  1. ishara
    ishara avatar
    4 posts
    Member since:
    Jun 2011

    Posted 16 Nov 2012 Link to this post

    Can we add RichTextBox to PropertyGird?
    also when i add a RadRichTextBox to Property grid it seem like showing the cursor somewhere else and even cant type.
    please help!!

    Ishara
  2. Plamen
    Admin
    Plamen avatar
    132 posts

    Posted 21 Nov 2012 Link to this post

    Hello Ishara,

    Thank you for writing.

    When RadPropertyGrid is not in read-only mode users can edit the content of the selected item. There are a number of built-in editors which are used for editing different data types. These editors can be customized or can be replaced by custom editors. Here you can find an article explaining how to create custom editor: http://www.telerik.com/help/winforms/propertygrid-editors-using-custom-editor.html.

    Attached you can find a sample demo application where the standard text box editors are replaced with RichTextBox editors. Note that RadRichTextBoxElement does not have 'Text' property since it supports different formats for importing and exporting documents. In the attached demo I use TxtFormatProvider, which is used for importing/exporting of plain text document. If you want to use another format, you can read this documentation article and use the desired format: http://www.telerik.com/help/winforms/richtextbox-faq.html

    Here you can read about the specific events exposed by the RadRichTextBox control: http://www.telerik.com/help/winforms/richtextbox-events.html

    I hope this helps. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Plamen
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. ishara
    ishara avatar
    4 posts
    Member since:
    Jun 2011

    Posted 08 Dec 2012 Link to this post


    Hi Plamen,

    Thanks for your reply and example..i managed to add a richtextbox to the propertygrid. but when i quit the editor it change the colors to black again..only while editor active it shows the colors.. is it by design or can we have colors after editing as well?

    Thank,
    Ishara
  5. Plamen
    Admin
    Plamen avatar
    132 posts

    Posted 12 Dec 2012 Link to this post

    Hi ishara,

    Thank you for writing.

    In the attached demo below I used TxtFormatProvider, which is used for importing/exporting of plain text document. This provider removes all text formatting. In your case you could use HtmlFormatProvider to import/export HTML documents and this will allow you to make changes:
    using Telerik.WinControls.RichTextBox.FileFormats.Html;

    public
    override object Value
    {
        get
        {
            HtmlFormatProvider provider = new HtmlFormatProvider();
            return provider.Export(this.Editor.Document);
        }
        set
        {
            string text = Convert.ToString(value);
            if (text != this.Value)
            {
                HtmlFormatProvider provider = new HtmlFormatProvider();
                this.Editor.Document =  provider.Import(Encoding.Default.GetBytes(text));
            }
        }
    }

    In addition, you could take a look at our documentation article about Import/Export Settings: http://www.telerik.com/help/winforms/richtextbox-features-import-export-import-export-settings.html.

    I hope this helps. Let me know if you have further enqueries.

    All the best,
    Plamen
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top