GridControl.CustomColumnDisplayText Event

Allows you to customize a data cell's display text.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.1.dll

Declaration

public event CustomColumnDisplayTextEventHandler CustomColumnDisplayText
Public Event CustomColumnDisplayText As CustomColumnDisplayTextEventHandler

Event Data

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

Property Description
Column Gets the column which owns the processed cell.
DisplayText Gets or sets the display text for the cell currently being processed.
ListSourceIndex Gets the index of a record in a data source that corresponds to the processed data row.
Row Gets the row which owns the processed cell.
RowHandle Gets the processed row's handle.
ShowAsNullText Specifies whether text corresponding to a null value appears faded.
Source Gets the grid control that raised the event.
Value Gets the processed cell's value.

Remarks

The CustomColumnDisplayText event can be used to display custom text within any cell. This event is fired for both bound and unbound columns. The text provided via this event will be used when the grid is printed.

Initially, the CustomColumnDisplayTextEventArgs.DisplayText parameter contains the cell's current display text. To provide custom display text, assign the required string to this property.

<dxg:GridColumn FieldName="Value" /> 
void grid_CustomColumnDisplayText(object sender, DevExpress.Xpf.Grid.CustomColumnDisplayTextEventArgs e) {
    if (e.Column.FieldName == "Value")
        e.DisplayText = string.Format("{0:n2}", e.Value);
} 

The CustomColumnDisplayText event is called in various instances:

  • To provide a cell's display text when data is not sorted by a column.

  • To provide column display text and compare the supplied strings when data is grouped or sorted by this column.

    In this instance, the event's RowHandle and ListSourceRowIndex parameters return invalid values, and it is not possible to determine the currently processed row, and therefore obtain other cell values.

  • To supply text to display within a column's Filter DropDown.

    In this instance, the event's RowHandle and ListSourceRowIndex parameters return invalid values, and it's not possible to determine the currently processed row, and therefore obtain other cell values.

This means, that in most instances the CustomColumnDisplayText event cannot be used to supply custom display text to a column based on values of other cells. A solution to this task is to create an unbound column to provide custom display text.

See Also