To reproduce:
- Select several words by holding the control key.
- Paste some text.
Result: the first word is replaced, the other are deleted
Expected: the text should be pasted in all selected places
Workaround:
private void RadRichTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
if (e.Command is PasteCommand)
{
var ranges = radRichTextBox.Document.Selection.Ranges.ToList();
if (ranges.Count > 1)
{
e.Cancel = true;
foreach (var range in ranges)
{
radRichTextBox.Document.Selection.Clear();
radRichTextBox.Document.Selection.AddSelectionStart(range.StartPosition);
radRichTextBox.Document.Selection.AddSelectionEnd(range.EndPosition);
PasteNewText();
}
}
}
}
public void PasteNewText()
{
DocumentFragment clipboardDocument = null;
string clipboardText = null;
bool clipboardContainsData = false;
if (ClipboardEx.ContainsText(null))
{
clipboardText = ClipboardEx.GetText(null);
clipboardContainsData = true;
}
if (!clipboardContainsData)
{
return;
}
if (clipboardDocument != null)
{
this.radRichTextBox.ActiveDocumentEditor.InsertFragment(clipboardDocument);
}
else if (!string.IsNullOrEmpty(clipboardText))
{
this.radRichTextBox.ActiveDocumentEditor.Insert(clipboardText);
}
}