Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Provide Custom Display Text for Data Cells

The following example demonstrates how to handle the ColumnView.CustomColumnDisplayText event to display custom display text in data cells. 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 = "";
}