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

How to programmatically add stylized text with in-text codes?

3 Answers 127 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Shann
Top achievements
Rank 1
Shann asked on 30 Mar 2021, 07:10 PM

Good Morning.

I am trying to figure out how to programmatically (C#) add text to the editor with styles built into to the string. The codes that the editor control accepts doesn't matter to me as I can run a conversion from the string to what's acceptable by the control. I've looked through the documentation that I could find and only found things like "control.method" instead of the control actually reading the text to find out what to "Switch on and off", etc.

For a crude example, an html string might consist of "hello my <b>bold</b> string.". What would I replace <b> and </b> with so that the editor can translate them into bold and non-bold? I am only using HTML has an example, it could be anything.

Normally, I wouldn't use the editor control as it has a tons of stuff I would never use, but it seems to be the only control available for possibly support styles, colors, and inline images (emoticons).

3 Answers, 1 is accepted

Sort by
0
Shann
Top achievements
Rank 1
answered on 30 Mar 2021, 07:58 PM

Hmm. I cannot edit my post. In short, I am looking to append formatted text to the editor. I figured I would first start just a straight import, however, the documentation is out of date (ref: https://docs.telerik.com/devtools/winforms/controls/richtexteditor/import-export/html/htmlformatprovider) as the example for importing has unrelated error for the RadRichTextEditor from "Telerik UI for WinForms - Editors 2021 R1 (NuGet)".

0
Accepted
Tanya
Telerik team
answered on 01 Apr 2021, 03:54 PM

Hello Shann,

Indeed, you will first need to import the content so it can be parsed to the document model of RichTextEditor. After importing, you can use the RadDocumentMerger class and its functionalities to merge the document into the target one.

As you mentioned that you are experiencing issues with the import API, I have checked the information and examples inside the article but everything seems correct there. Are you getting an error? What is it? Can you please verify that the HtmlFormatProvider class from the Telerik.WinForms.Documents.FormatProviders.Html namespace is being used?

Regards,
Tanya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Shann
Top achievements
Rank 1
answered on 01 Apr 2021, 04:20 PM

ah! something as simple as that would do it! VS plugged in the following by default:

 

Telerik.Windows.Documents.Flow.FormatProviders.Html

Thank you for the steps. With that information, that tells me I am most likely using the wrong control for what I am trying to accomplish. I'll look through the other controls to see if they have what I need.

Thank you for your help.

 

Tags
RichTextEditor
Asked by
Shann
Top achievements
Rank 1
Answers by
Shann
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or