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

Table.Index Property

Returns the table’s index in the table collection.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
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:

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 {
            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