RichTextBox - Filter out hyperlinks during paste command

1 posts, 0 answers
  1. C
    C avatar
    43 posts
    Member since:
    Jul 2014

    Posted 03 Dec 2014 Link to this post

    I'd like to filter out hyperlinks when the user pastes into a RadRichTextBox editor control.   We are using RichTextBoxUI.dll from UI for WPF version 2014.2.617.40.

    The examples found the following threads set e.Cancel = true to cancel the paste operation. 
    e.Cancel is not visible in Telerik.Windows.Controls.RichTextBoxUI.DLL v2014.2.617.40 
    How can the paste command be cancelled?  For example, cancel any paste command with an image in it.

    The second related thread has this sample code to remove hyperlinks.
    void radRichTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
       if (e.Command is PasteCommand)    
                  DocumentFragment fragment = ClipboardEx.GetDocument();        
                  if (fragment != null)        
                            TxtFormatProvider provider=new TxtFormatProvider();            
                            string plainText = provider.Export(fragment.ToDocument());            
                            this.radRichTextBox.InsertFragment(new DocumentFragment(provider.Import(plainText)));
                            e.Cancel = true;        

    Related threads:
    - How to paste plain text
    - How to remove hyperlinks
    - Preventing paste of images (Silverlight)

Back to Top