Skip to main content
All docs
V25.1
  • ITableRowHeight Interface

    Contains row height settings.

    Namespace: DevExpress.Blazor.RichEdit

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

    NuGet Package: DevExpress.Blazor.RichEdit

    Declaration

    public interface ITableRowHeight

    The following members return ITableRowHeight objects:

    Remarks

    Use the TableRow.Height property to identify the row height. Call a row’s ChangePropertiesAsync method to change the following height settings:

    Height.Value
    Explicitly specifies the row height in twips.
    Height.Type
    Allows you to switch between the following row height calculation modes:
    • Auto – The TableRowHeight.Value property does not affect the row height. The height is calculated automatically based on content.
    • Exact – The TableRowHeight.Value property specifies the row height in twips.
    • Minimum – The TableRowHeight.Value property specifies the row minimum height in twips. The component can increase the height of a row to fit its content.

    Adjust Height to Content

    The following code example adjusts a table’s height according to 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 = firstTable.Rows.Count - 1; i >= 0 ; i--)
                    for (int j = firstTable.Rows[i].Cells.Count - 1; j >= 0 ; j--) {
                        var cellPosition = firstTable.Rows[i].Cells[j].Interval.Start;
                        await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
                }
                // Customizes the table
                foreach(TableRow row in firstTable.Rows) {
                    await row.ChangePropertiesAsync(properties => {
                        properties.Height.Type = TableRowHeightType.Auto;
                    });
                }
                richEdit.DocumentAPI.EndUpdate();
            }
            catch (OperationCanceledException e) {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
        }
    }
    

    Fixed Table Height

    The following code snippet sets the row height to 1 centimeter:

    <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 = firstTable.Rows.Count - 1; i >= 0 ; i--)
                    for (int j = firstTable.Rows[i].Cells.Count - 1; j >= 0 ; j--) {
                        var cellPosition = firstTable.Rows[i].Cells[j].Interval.Start;
                        await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
                }
                // Customizes the table
                foreach(TableRow row in firstTable.Rows){
                    await row.ChangePropertiesAsync(properties => {
                        properties.Height = new TableRowHeight(TableRowHeightType.Exact, UnitConverter.CentimetersToTwips(1));
                    });
                }
                richEdit.DocumentAPI.EndUpdate();
            }
            catch (OperationCanceledException e) {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
        }
    }
    
    See Also