Back to Devexpress

TableCell.CharacterProperties Property

blazor-devexpress-dot-blazor-dot-richedit-dot-tablecell-5c0d5bfd.md

latest3.1 KB
Original Source

TableCell.CharacterProperties Property

Returns formatting settings of characters in the cell.

Namespace : DevExpress.Blazor.RichEdit

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

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public ICharacterProperties CharacterProperties { get; }

Property Value

TypeDescription
ICharacterProperties

Formatting settings of cell characters.

|

Remarks

The cell stores its text formatting settings in the CharacterProperties property. Call the ChangePropertiesAsync method to change formatting of all characters in the cell.

The following code snippet applies the Arial font typeface to all characters in a 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 {
            var columnCount = 4;
            var rowCount = 5;
            richEdit.DocumentAPI.BeginUpdate();
            // Creates a table
            Table myTable = await richEdit.DocumentAPI.Tables.CreateAsync(0, columnCount, rowCount);
            for (int i = rowCount-1; i >=0 ; i--)
                for (int j = columnCount-1; j >=0 ; j--) {
                    var cellPosition = myTable.Rows[i].Cells[j].Interval.Start;
                    await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
                }
            // Customizes the table
            myTable = await richEdit.DocumentAPI.Tables.GetAsync(0);
            foreach (TableRow row in myTable.Rows)
                foreach (TableCell cell in row.Cells)
                    await cell.ChangePropertiesAsync(properties => {
                        properties.CharacterProperties.FontName = "Arial";
                    });
            richEdit.DocumentAPI.EndUpdate();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}

See Also

Tables in Blazor Rich Text Editor

TableCell Class

TableCell Members

DevExpress.Blazor.RichEdit Namespace