以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  单元格颜色的动态设定  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=145226)

--  作者:wangjh8888
--  发布时间:2020/1/13 10:03:00
--  单元格颜色的动态设定
老师 早
有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

--  作者:有点蓝
--  发布时间:2020/1/13 10:07:00
--  
直接使用扩展列即可,不需要写代码:http://www.foxtable.com/webhelp/topics/0083.htm