Paste plain text when copying\pasting in same RadRichTextBox

2 posts, 1 answers
  1. Chris
    Chris avatar
    8 posts
    Member since:
    Apr 2014

    Posted 02 Jan 2015 Link to this post

    I am trying to override the default clipboard behavior to only support pasting plain text using the following code:

    var clipboardHandler = new ClipboardHandler();
    clipboardHandler.ClipboardDataFormat = DataFormats.Text;
    clipboardHandler.DocumentFormatProvider = new TxtFormatProvider();

    This seems to work appropriately when pasting from an application such as MS Word. However, if I copy from a RadRichTextBox and then paste into the same RadRichTextBox, the formatting is preserved. How can I also paste plain text when copying from the same RadRichTextBox I am pasting into?
  2. Answer
    Boby avatar
    586 posts

    Posted 06 Jan 2015 Link to this post

    Hi Chris,
    Copy/pasting from RadRichTextBox to RadRichTextBox cannot be controlled on Clipboard handler level.

    You can instead change the default pasting behavior:
        radRichTextBox.CommandExecuting += radRichTextBox_CommandExecuting;
    void radRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
        if (e.Command is PasteCommand)
            e.Cancel = true;

    Using this approach, you won't even need to change the registered clipboard handlers.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top