Skip to main content

Paragraph.ListIndex Property

Gets the index of the list to which the paragraph belongs.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public int? ListIndex { get; }

Property Value

Type Description
Nullable<Int32>

The list index or null if the paragraph does not belong to a list.

Remarks

A list in a document is a series of paragraphs. Each paragraph contains information about the list (ListIndex) and the list level (ListLevelIndex) to which it belongs, if any.

Call the AddToListAsync(List, Int32, CancellationToken) method to set the paragraph’s ListIndex and ListLevelIndex properties, apply a list format style to the paragraph, and add the paragraph to the list.

The RemoveFromListAsync(CancellationToken) method allows you to remove the paragraph from the list.

The following code snippet removes all paragraphs from a list.

<DxRichEdit @ref="richEdit" />

@code {
    DxRichEdit richEdit;
    Document documentAPI;
    /* 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 {
            documentAPI = richEdit.DocumentAPI;
            IReadOnlyList<Paragraph> paragraphs = await documentAPI.Paragraphs.GetAllAsync();
            foreach (Paragraph p in paragraphs)
                if (p.ListIndex != null)
                    await p.RemoveFromListAsync();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}
See Also