Steve
asked on 07 May 2025, 07:35 AM
| edited on 07 May 2025, 07:35 AM
Hi,
If I select multiple rows in a table in a RichTextBox, the delete options become un-selectable. How can I change this to enable me to delete multiple selected rows from a table?
1 Answer, 1 is accepted
0
Stenly
Telerik team
answered on 09 May 2025, 12:26 PM
Hello Steve,
The observed behavior is expected, as currently, the RadRichTextBox control does not provide this functionality out of the box. When there is a selection, the UI commands will be disabled.
However, we have an open feature request regarding this functionality, which can be found at the following link, where it can be voted for, as well as followed, in order to get notified via e-mail when its status gets changed:
With this in mind, for the time being, a possible approach to achieve this would be to retrieve the selected rows, deselect them, and manually delete them. The following code snippet showcases a sample implementation of this suggestion, which could be executed on a button's Click event:
HashSet<TableRow> rowsToDelete = new HashSet<TableRow>();
foreach (var range inthis.radRichTextBox.Document.Selection.Ranges.Where(range => range.RangeType == SelectionRangeType.TableCell || range.RangeType == SelectionRangeType.TableRow))
{
rowsToDelete.Add(range.StartPosition.GetCurrentTableRowBox().AssociatedTableRow);
}
if (rowsToDelete.Any())
{
this.radRichTextBox.Document.Selection.Clear();
this.radRichTextBox.BeginUndoGroup();
foreach (var row in rowsToDelete)
{
this.radRichTextBox.DeleteTableRow(row);
}
this.radRichTextBox.EndUndoGroup("Delete table row(s).");
this.radRichTextBox.UpdateEditorLayout();
}
With this being said, I hope the provided information will be of help to you.