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

Add RichTextBox to PropertyGird

3 Answers 173 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
ishara
Top achievements
Rank 1
ishara asked on 16 Nov 2012, 03:26 PM
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

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 21 Nov 2012, 01:19 PM
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.
0
ishara
Top achievements
Rank 1
answered on 08 Dec 2012, 12:46 PM

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
0
Plamen
Telerik team
answered on 12 Dec 2012, 04:50 PM
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.
Tags
PropertyGrid
Asked by
ishara
Top achievements
Rank 1
Answers by
Plamen
Telerik team
ishara
Top achievements
Rank 1
Share this question
or