Skip to main content
All docs
V24.1

Table.ParentCell Property

Returns the cell that contains the current table.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public TableCell ParentCell { get; }

Property Value

Type Description
TableCell

The cell that contains the current table or null if the table is not nested.

Remarks

The Rich Text Editor component allows users to place tables within tables. Use the ParentCell property to obtain the cell that contains the current table. If the table is not nested, the ParentCell property returns null.

The following example applies the Grid Table 4 Accent 4 style to all nested tables:

<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 {
            richEdit.DocumentAPI.BeginUpdate();
            var Tables = await richEdit.DocumentAPI.Tables.GetAllAsync();
            for (int i=0; i < Tables.Count; i++) {
                if (Tables[i].ParentCell != null)
                    await Tables[i].ChangePropertiesAsync(properties => {
                        properties.StyleName = TableStyleName.GridTable4Accent4;
                    });
            }
            richEdit.DocumentAPI.EndUpdate();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}
See Also