HOME PAGE | DOWNLOAD | TUTORIALS | XtraReports
Devexpress

Sunday, July 22, 2012

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:

 

C#

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 = "";

}

 

VB

Imports DevExpress.XtraGrid.Views.Base
 
Private Sub GridView1_CustomColumnDisplayText(ByVal sender As Object, _
ByVal e As CustomColumnDisplayTextEventArgs) Handles GridView1.CustomColumnDisplayText
   If e.Column.FieldName = "Discount" Then
      If e.Value = 0 Then e.DisplayText = ""
   End If
End Sub

 

 

No comments:

Post a Comment