以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]关于DrawCell的求助  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=79675)

--  作者:huangfanzi
--  发布时间:2016/1/7 10:40:00
--  [求助]关于DrawCell的求助
以下代码实现了某数字列中的值为-1时,此格子以样式1设置的颜色显示,
现希望出现-1值的所在的行能以样式2的颜色进行整行上色。
谢谢老师!

If e.Table.Rows.Count > 0 Then   
    e.Table.DataTable.AddUserStyle("样式1", Color.Pink,Color.Black)
    e.Table.DataTable.AddUserStyle("样式2", Color.GreenYellow,Color.Black)
    If e.Col.IsNumeric  Then
        If e.Row(e.Col.Name) = -1
            e.style = "样式1"
        End If
    End If
End If

--  作者:大红袍
--  发布时间:2016/1/7 10:51:00
--  
If e.Table.Rows.Count > 0 Then
    e.Table.DataTable.AddUserStyle("样式1", Color.Pink,Color.Black)
    e.Table.DataTable.AddUserStyle("样式2", Color.GreenYellow,Color.Black)
    For Each c As Col In e.Table.cols
        If c.IsNumeric AndAlso e.Row(c.name) = -1 Then
            e.style = "样式2"
            Exit For
        End If
    Next
End If

--  作者:huangfanzi
--  发布时间:2016/1/7 11:00:00
--  
老师,我上面没说清楚,对不起,我想实现的效果是出现-1的格子显示样式1,同时此行其它格子显示样式2。
目的是让用户知道,某行颜色为样式2时,此行出现了错误,具体哪个格子出现的错误,就去找下样式1的颜色。

--  作者:大红袍
--  发布时间:2016/1/7 11:08:00
--  
If e.Table.Rows.Count > 0 Then
    e.Table.DataTable.AddUserStyle("样式1", Color.Pink,Color.Black)
    e.Table.DataTable.AddUserStyle("样式2", Color.GreenYellow,Color.Black)
    For Each c As Col In e.Table.cols
        If c.IsNumeric AndAlso e.Row(c.name) = -1 Then
            e.style = "样式2"
            Exit For
        End If
    Next
    If e.Col.IsNumeric  Then
        If e.Row(e.Col.Name) = -1
            e.style = "样式1"
        End If
    End If
End If