Skip to main content

DxGridColumn.TextAlignment Property

Specifies the alignment of text in column cells.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(GridTextAlignment.Auto)]
[Parameter]
public GridTextAlignment TextAlignment { get; set; }

Property Value

Type Default Description
GridTextAlignment Auto

A GridTextAlignment enumeration value.

Available values:

Name Description
Auto

Aligns the text based on cell content and column data type.

Left

Aligns cell text to the left.

Center

Centers cell text.

Right

Aligns cell text to the right.

Remarks

The Grid component aligns the contents of data and footer cells based on the cell data type and column type. For example, the default behavior of the DxGridCommandColumn and DxGridSelectionColumn is to center their content.

The default text alignment

Use the TextAlignment property to change the text alignment in column cells. The following example applies this property:

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="GridDataSource">
    <Columns>
        <DxGridDataColumn FieldName="ProductName" />
        <DxGridDataColumn FieldName="UnitPrice"
                          TextAlignment="GridTextAlignment.Left" />
        <DxGridDataColumn FieldName="QuantityPerUnit"
                          TextAlignment="GridTextAlignment.Center" />
        <DxGridDataColumn FieldName="UnitsInStock" />
        <DxGridSelectionColumn Width="80px" TextAlignment="GridTextAlignment.Right"></DxGridSelectionColumn>
    </Columns>
    <TotalSummary>
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Max" FieldName="UnitPrice" />
    </TotalSummary>
</DxGrid>

@code {
    IEnumerable<object> GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        GridDataSource = Northwind.Products.ToList();
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

The Grid's column text alignment

Use the following properties to align column captions:

Implements

See Also