【发布时间】:2016-10-25 14:20:52
【问题描述】:
这是我有条件地格式化特定 Gridview 单元格的代码(值是我转换为十进制的字符串)
If e.Row.Cells(0).Text = "Total" Then
Dim c2 As Decimal
Decimal.TryParse(e.Row.Cells(7).Text, c2)
If c2 >= 0 And c2 <= 84 Then
e.Row.Cells(7).BackColor = Drawing.Color.Firebrick
e.Row.Cells(7).ForeColor = Drawing.Color.White
End If
If c2 >= 85 Then
e.Row.Cells(7).BackColor = Drawing.Color.LimeGreen
e.Row.Cells(7).ForeColor = Drawing.Color.Black
End If
End If
问题是小数没有 Null 值
所以我希望单元格背景颜色为空时为白色(如无数字),目前它显示为 Firebrick,因为它的类 0 与 nothing/null 相同
关于如何实现这一点的任何想法?
【问题讨论】:
-
使用
CellFormatting事件DataGridView。同时检查DBNull可能是您正在寻找的。span>