Skip to main content

CharacterProperties.CopyFrom(TextSpan) Method

Duplicates the properties of the specified text span into the current instance of the CharacterProperties class.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public void CopyFrom(
    TextSpan textSpan
)

Parameters

Name Type Description
textSpan TextSpan

The source text span.

Remarks

The CopyFrom method duplicates the properties of the specified TextSpan object into the instance of the CharacterProperties class that this method is called from.

Send the result CharacterProperties object to the ChangePropertiesAsync method as a parameter to copy all properties of a text span to another span.

<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;
            TextSpan characters = await documentAPI.AddTextAsync("New Text");
            @* ... *@
            IReadOnlyList<Paragraph> paragraphs = await documentAPI.Paragraphs.GetAllAsync();
            foreach (Paragraph p in paragraphs) {
                TextSpan currentCharacters = await documentAPI.GetTextSpanAsync(p.Interval);
                await currentCharacters.ChangePropertiesAsync(properties => {
                    properties.CopyFrom(characters);
                });
            }
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}
See Also