Skip to main content
All docs
V24.1

Table.Index Property

Returns the table’s index in the table collection.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public int Index { get; }

Property Value

Type Description
Int32

An index.

Remarks

The following example creates a table at the end of the main sub-document and copies style settings from the first table to the newly created table:

<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();
            // Creates a table at the end of the main sub-document
            var interval = await richEdit.DocumentAPI.GetIntervalAsync();
            var position = interval.Length - 1;
            Table table = await richEdit.DocumentAPI.Tables.CreateAsync(position, 3, 4);
            // Customizes the table
            if (table.Index != 0){
                var firstTable = await richEdit.DocumentAPI.Tables.GetAsync(0);
                await table.ChangePropertiesAsync(properties => {
                    properties.StyleName = firstTable.StyleName;
                    properties.TableStyleOptions = firstTable.TableStyleOptions;
                });
            }
            richEdit.DocumentAPI.EndUpdate();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}
See Also