ScriptSK / how-to-customize-copy-and-paste-commands-e3665

.NET, WinForms, XtraRichEdit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to customize copy and paste commands

This example illustrates how to override CopySelectionCommand and PasteSelectionCommand behavior via the IRichEditCommandFactoryService substitution. This approach is based on the How to replace standard XtraRichEdit command with your own custom command example.

Customized CopySelectionCommand contains code for copying selection to the Clipboard in an HTML Clipboard Format (see the HtmlHelper.GetHtmlClipboardFormat() method), which is not implemented by default at the XtraRichEdit source code level. This allows you to copy RichEditControl content and paste it directly to a certain control that can accept HTML-formatted data from the Clipboard (e. g. ASPxHtmlEditor). Note that images are embedded into resultant HTML according to the Data URI scheme specification to avoid dependency on the image location (it may not be resolved by the target application). Refer to the Building a mail application with the RichEditControl example to learn more on this approach.

As for customized PasteSelectionCommand, it simply retrieves plain (unformatted) text from the Clipboard and pastes this text into the RichEditControl.

See Also:
SubDocument.GetText Method
SubDocument.GetRtfText Method
SubDocument.GetHtmlText Method


About

.NET, WinForms, XtraRichEdit

License:Other


Languages

Language:C# 88.7%Language:Visual Basic .NET 11.3%