Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TableRows Class

Contains members that allow you to manage a table’s rows.

Namespace: DevExpress.Blazor.RichEdit

Assembly: DevExpress.Blazor.RichEdit.v24.2.dll

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public class TableRows :
    ReadOnlyList<TableRow>

The following members return TableRows objects:

#Remarks

A Table consists of cells combined into rows. Use the Rows property to access the table row collection. Call the InsertAsync/RemoveAsync method to add/remove a row to/from the table.

Read Tutorial: Tables

The following example removes an existing row and adds two new rows to a table:

Razor
<DxRichEdit @ref="richEdit" />

@code {
    DxRichEdit richEdit;
    protected override async Task OnAfterRenderAsync(bool firstRender) {
        if (firstRender)
            try {
                await InitializeDocument();
            }
            catch (TaskCanceledException) { }
        await base.OnAfterRenderAsync(firstRender);
    }

    async Task InitializeDocument() {
    /* Surround the code that contains an asynchronous operation with a try-catch block to handle
    the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
        try {
            var columnCount = 4;
            var rowCount = 5;
            richEdit.DocumentAPI.BeginUpdate();
            // Creates a table
            Table firstTable = await richEdit.DocumentAPI.Tables.CreateAsync(0, columnCount, rowCount);
            for (int i = rowCount-1; i >=0 ; i--)
                for (int j = columnCount-1; j >=0 ; j--) {
                    var cellPosition = firstTable.Rows[i].Cells[j].Interval.Start;
                    await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
                }
            foreach (TableRow row in firstTable.Rows) {
                // Removes the first row
                await firstTable.Rows.RemoveAsync(0);
                // Inserts a row above the first row
                await firstTable.Rows.InsertAsync(0, false);
                // Inserts a row below the last row
                await firstTable.Rows.InsertAsync(firstTable.Rows.Count - 1, true);
            }
            richEdit.DocumentAPI.EndUpdate();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}

#Inheritance

Object
DevExpress.Blazor.RichEdit.Internal.ReadOnlyList<TableRow>
TableRows
See Also