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

RichTextBox - Filter out hyperlinks during paste command

0 Answers 90 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
C
Top achievements
Rank 1
C asked on 03 Dec 2014, 10:27 PM
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 http://www.telerik.com/forums/paste-plain-text
- How to remove hyperlinks http://www.telerik.com/forums/remove-hyperlinks-when-executing-pastecommand
- Preventing paste of images http://www.telerik.com/forums/limiting-the-radrichtextbox (Silverlight)

No answers yet. Maybe you can help?

Tags
RichTextBox
Asked by
C
Top achievements
Rank 1
Share this question
or