ColumnView.RowCellDefaultAlignment Event

Enables you to specify content alignment for individual cells.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[DXCategory("Appearance")]
public event RowCellAlignmentEventHandler RowCellDefaultAlignment
<DXCategory("Appearance")>
Public Event RowCellDefaultAlignment As RowCellAlignmentEventHandler

Event Data

The RowCellDefaultAlignment event's data class is RowCellAlignmentEventArgs. The following properties provide information specific to this event:

Property Description
CellValue Returns the currently processed cell value. Inherited from CustomRowCellEventArgs.
Column Gets the column to which the currently processed cell corresponds. Inherited from CustomRowCellEventArgs.
HorzAlignment Gets or sets the cell content's default horizontal alignment.
RowHandle Gets the handle of the row that contains the processed cell. Inherited from CustomRowCellEventArgs.

Remarks

Cell values are automatically aligned with respect to their type, and the kind of editor used to modify them. This default behavior can be overridden by handling the RowCellDefaultAlignment event. Handling this event enables you to align values not only within columns, but within individual cells. Use the RowCellAlignmentEventArgs.HorzAlignment parameter to specify the required default horizontal alignment.

The event's CustomRowCellEventArgs.Column and CustomRowCellEventArgs.RowHandle parameters allow you to identify the column and row that contain the processed cell.

Note that RowCellDefaultAlignment event handling is in effect for columns that have the AppearanceCell.TextOptions.HAlignment property set to HorzAlignment.Default.

The alignment specified by the RowCellDefaultAlignment event handler can be overridden by handling the GridView.RowCellStyle, GridView.CustomDrawCell and CardView.CustomDrawCardFieldValue events, or by setting a column's AppearanceCell.TextOptions.HAlignment property.

Examples

The following sample code handles the ColumnView.RowCellDefaultAlignment event to specify the default horizontal alignment for cells whose row handle is either 4 or 5. Cells owned by the Category column are omitted.

The image below shows the Grid Control's look and feel after sample code execution.

GridView_RowCellDefaultAlignment

using DevExpress.XtraGrid.Views.Base;

private void gridView1_RowCellDefaultAlignment(object sender, RowCellAlignmentEventArgs e) {
    if(e.Column.FieldName != "Category") 
        if(e.RowHandle == 4 || e.RowHandle == 5) 
            e.HorzAlignment = DevExpress.Utils.HorzAlignment.Far;
}
See Also