Unplanned
Last Updated: 10 Aug 2020 06:12 by ADMIN
Mattia
Created on: 10 Aug 2020 06:12
Category: RichTextBox
Type: Bug Report
3
RichTextBox: Deleting image produced by the evaluation of INCLUDEPICTURE field deletes the field but not the image
The first time users select an image and press Delete deletes only the fields and not the image.
Workaround: Attach to CommandExecuting and CommandExecuted events of RadRichTextBox and ensure the image is deleted using the following code:
private void radRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
{
    if (e.Command is DeleteCommand && imageToDelete!=null)
    {
        this.radRichTextBox.Document.Selection.Clear();
        this.radRichTextBox.Document.Selection.AddDocumentElementToSelection(imageToDelete);
        this.radRichTextBox.Delete(true);
        this.imageToDelete = null;
    }
}

private ImageInline imageToDelete;
void radRichTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
    if (e.Command is DeleteCommand)
    {
        var selectedBoxes = this.radRichTextBox.Document.Selection.GetSelectedBoxes().ToList();
        if (selectedBoxes.Count() == 2 && selectedBoxes[0].AssociatedInline is FieldRangeStart && selectedBoxes[1].AssociatedInline is ImageInline)
        {
            imageToDelete = selectedBoxes[1].AssociatedInline as ImageInline;
        }
    }
}

0 comments