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

How to: Provide Custom Display Text for Data Cells

The following example demonstrates how to provide custom display text for data cells via the ColumnView.CustomColumnDisplayText event. In the example empty strings are displayed within the “Discount” column’s cells if they contain zero values.

The result is shown below:

ColumnView.CustomColumnDisplayText

using DevExpress.XtraGrid.Views.Base;

private void gridView1_CustomColumnDisplayText(object sender, 
CustomColumnDisplayTextEventArgs e) {
   if(e.Column.FieldName == "Discount")
      if(Convert.ToDecimal(e.Value) == 0) e.DisplayText = "";
}