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

GridControl.CustomColumnDisplayText Event

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

Namespace: DevExpress.Xpf.Grid

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

NuGet Packages: DevExpress.WindowsDesktop.Wpf.Grid.Core, DevExpress.Wpf.Grid.Core

Declaration

public event CustomColumnDisplayTextEventHandler CustomColumnDisplayText

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.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomColumnDisplayText event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also