How to Delete Multiple Rows in a Table

1 Answer 31 Views
RichTextBox
Steve
Top achievements
Rank 2
Iron
Iron
Iron
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

Sort by
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:

RichTextBox: Add ability to delete all selected table rows/columns

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 in this.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.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
RichTextBox
Asked by
Steve
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or