Foxtable(狐表)用户栏目专家坐堂 → 单元格颜色的动态设定


  共有4426人关注过本帖树形打印复制链接

主题:单元格颜色的动态设定

帅哥哟,离线,有人找我吗?
wangjh8888
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:502 积分:4924 威望:0 精华:0 注册:2016/7/11 10:12:00
单元格颜色的动态设定  发帖心情 Post By: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

 回到顶部