Skip to main content
A newer version of this page is available. .

DxGridColumn.TextAlignment Property

Specifies the alignment of text in column cells.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.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 in the column based on cell content and column data type.

Left

Aligns cell text to the left.

Center

Centers the 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 shows how to apply 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

Implements

See Also