Skip to main content
All docs
V21.2

Paragraph.AddToListAsync(List, Int32) Method

Adds the paragraph to a list.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public ValueTask<bool> AddToListAsync(
    List list,
    int listLevelIndex = 0
)

Parameters

Name Type Description
list List

A list to which the paragraph is added.

Optional Parameters

Name Type Default Description
listLevelIndex Int32 0

A list level to which the paragraph is added.

Returns

Type Description
ValueTask<Boolean>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is true if the operation ends successfully; otherwise, it is false.

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 method to set the ListIndex and ListLevelIndex properties, apply a list format style to the paragraph, and add the paragraph to the 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 cancelled. */
        try {
            documentAPI = richEdit.DocumentAPI;
            @* ... *@
            List list = await documentAPI.Lists.CreateAsync(ListType.Number);
            await documentAPI.AddTextAsync("Paragraph 1");
            Paragraph par1 = await documentAPI.Paragraphs.GetAsync(0);
            await par1.AddToListAsync(list);
            Paragraph par2 = await documentAPI.Paragraphs.CreateAsync();
            await documentAPI.AddTextAsync("Paragraph 2");
            await par2.AddToListAsync(list,1);
            Paragraph par3 = await documentAPI.Paragraphs.CreateAsync();
            await documentAPI.AddTextAsync("Paragraph 3");
            await par3.AddToListAsync(list,1);
            Paragraph par4 = await documentAPI.Paragraphs.CreateAsync();
            await documentAPI.AddTextAsync("Paragraph 4");
            await par4.AddToListAsync(list);
            Paragraph par5 = await documentAPI.Paragraphs.CreateAsync();
            await documentAPI.AddTextAsync("Paragraph 5");
            await par5.AddToListAsync(list);
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

The image below shows the result.

Rich Edit - List

Call the RemoveFromListAsync() method to remove the paragraph from the list.

await par5.RemoveFromListAsync();

Rich Edit - Remove a Paragraph from List

See Also