Skip to main content
All docs
V25.1
  • Table.ContentVerticalAlignment Property

    Returns the vertical alignment of content in table cells.

    Namespace: DevExpress.Blazor.RichEdit

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

    NuGet Package: DevExpress.Blazor.RichEdit

    Declaration

    public VerticalAlignment ContentVerticalAlignment { get; }

    Property Value

    Type Description
    VerticalAlignment

    An enumeration value.

    Available values:

    Name Description
    Top

    Aligns the items or text at the top.

    Center

    Aligns the items or text at the center.

    Bottom

    Aligns the items or text at the bottom.

    Remarks

    The Rich Text Editor component allows you to specify a content vertical alignment for the following elements:

    Table
    The ContentVerticalAlignment property stores the vertical alignment of content in table cells. Call the ChangePropertiesAsync method and specify the TableProperties.ContentVerticalAlignment setting to vertically align content in all cells simultaneously.
    Table Cell
    The ContentVerticalAlignment property stores the vertical alignment of cell content. Call the ChangePropertiesAsync method and specify the TableCellProperties.ContentVerticalAlignment setting to vertically align cell content.

    Note

    A cell’s ContentVerticalAlignment property takes priority over the table’s ContentVerticalAlignment property.

    The following example aligns content in table cells:

    Align Cell Content

    <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 firstTable = 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 = firstTable.Rows[i].Cells[j].Interval.Start;
                        await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
                    }
                // Customizes the table
                await firstTable.ChangePropertiesAsync(properties => {
                    properties.ContentHorizontalAlignment = HorizontalAlignment.Left;
                    properties.ContentVerticalAlignment = VerticalAlignment.Top;
                    properties.Width = new TableWidth(TableWidthType.Percent, 100);
                });
                foreach (TableRow row in firstTable.Rows)
                    await row.ChangePropertiesAsync(properties => {
                        properties.Height = new TableRowHeight(TableRowHeightType.Exact, 400);
                    });
                foreach (TableCell cell in firstTable.Rows[0].Cells)
                    await cell.ChangePropertiesAsync(properties => {
                        properties.ContentHorizontalAlignment = HorizontalAlignment.Center;
                        properties.ContentVerticalAlignment = VerticalAlignment.Center;
                    });
                richEdit.DocumentAPI.EndUpdate();
            }
            catch (OperationCanceledException e) {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
        }
    }
    
    See Also