Back to Devexpress

TableCell.SplitAsync(Int32, Int32, CancellationToken) Method

blazor-devexpress-dot-blazor-dot-richedit-dot-tablecell-dot-splitasync-x28-system-dot-int32-system-dot-int32-system-dot-threading-dot-cancellationtoken-x29.md

latest3.2 KB
Original Source

TableCell.SplitAsync(Int32, Int32, CancellationToken) Method

Splits the cell into multiple smaller cells.

Namespace : DevExpress.Blazor.RichEdit

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

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public ValueTask SplitAsync(
    int columnCount,
    int rowCount,
    CancellationToken cancellationToken = default(CancellationToken)
)

Parameters

NameTypeDescription
columnCountInt32

The number of columns in the result cell range.

| | rowCount | Int32 |

The number of rows in the result cell range.

|

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

An object that propagates a cancellation notification.

|

Returns

TypeDescription
ValueTask

A structure that stores an awaitable result of an asynchronous operation.

|

Remarks

Once you split a cell, its content moves to the first cell in the result cell range. All cells in the result range have the same appearance settings as the initial cell.

The following code snippet splits the first cell into 6 cells (3 columns and 2 rows):

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();
            Table firstTable = await richEdit.DocumentAPI.Tables.CreateAsync(0, columnCount, rowCount);
            await firstTable.Rows[0].Cells[0].SplitAsync(3, 2);
            richEdit.DocumentAPI.EndUpdate();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}

To merge multiple cells in a range, call the MergeCellsAsync method.

See Also

Tables in Blazor Rich Text Editor

TableCell Class

TableCell Members

DevExpress.Blazor.RichEdit Namespace