下面的示例演示了如何通过 ColumnView.CustomColumnDisplayText 事件,为数据单元格提供自定义显示文本。 在本示例中,如果单元格取值为 0,则在“Discount”列的单元格中显示空字符串。
结果显示如下:
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 = ""; } |
Visual Basic | 复制代码 |
---|---|
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 |