SyntaxEditor - Copying formatted text to clipboard

1 Answer 95 Views
SyntaxEditor
Simon
Top achievements
Rank 1
Iron
Iron
Simon asked on 31 May 2022, 10:56 PM | edited on 31 May 2022, 10:57 PM

Hi,

I suspect this is not possible but thought I'd ask just in case.

Say in the syntax editor we have all the coloring going on desired. Is it possible to programmatically copy the selected text that can then be pasted into other richtexteditors keeping the formatting?

Best example of this I can think of is with Microsoft sql management studio - if you copy a query into an email or word it keeps the same coloring and formatting.
It can also be done with the standard winform richtextedit:

Clipboard.SetText(myRichTextBox.Rtf, TextDataFormat.Rtf);

Then pasting that into another richtextbox or email or even word, will maintain all the formatting.

I did try the above with GetSelectedText() but that was a no go.

Regards

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Jun 2022, 06:03 AM
Hello, Simon,   

Indeed, SQL Management Studio and Visual Studio keep the rich text format when copying and pasting the content. However, please note that they are not just an editor but a complete application with a variety of features along with code editing.

Please have in mind that RadSyntaxEditor is a code editor and it is not a RadRichTextEditor. RadSyntaxEditor stores its content into text format. The control works with the underlying text document with the help of taggers. Taggers are used to identify spans of text and assign them a specific tag if they match a specific condition to achieve the respective coloring. Hence, it is not intended to give you the content in rich text format. That is why when you copy the content and then paste it in MS Word for example, it pastes the plain text. 

If you want to provide rich text format when copying and pasting the text content, the appropriate control for such purposes is RadRichTextEditor.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
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/.

Tags
SyntaxEditor
Asked by
Simon
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or