老师 早有A表(包含一“色标”列,该列存储表示不同颜色的RGB对应值(类型integer)),想利用DrawCell,和AfterLoadTableSetting来实现不同单元格的背景颜色随其色标值变化而不同,如何实现
下面代码不能实现上面效果,请教老师 如何修改 或者怎么实现
DrawCell:
If e.Col.IsNumeric AndAlso e.Col.Name = "色标" Then ''如果是数值型列,且是色标列
If e.Row.IsNull(e.Col.Name) = False '且该列已经输入内容
Dim Colorval As Integer = e.Row(e.Col.Name)
Dim colorstrhex As String =Format(Colorval ,"X").PadLeft(6,"0")
Dim str1 As String =colorstrhex.SubString(0,2)
Dim str2 As String =colorstrhex.SubString(2,2)
Dim str3 As String =colorstrhex.SubString(4,2)
Dim clr As Color = Color.FromARGB(255,hextodec(str1),hextodec(str2),hextodec(str3))
ClrSetcolor_B =color.red ''ClrSetcolor_B 在公共变量定义
e.Style = "ClrSet"
End If
End If
AfterLoadTableSetting:
With e.Table.DataTable
.AddUserStyle("ClrSet",ClrSetcolor_B,ClrSetcolor_F)
End With