Foxtable(狐表)用户栏目专家坐堂 → [求助]临时表如何标识行


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

主题:[求助]临时表如何标识行

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


加好友 发短信
等级:二尾狐 帖子:593 积分:5360 威望:0 精华:0 注册:2011/9/30 8:42:00
[求助]临时表如何标识行  发帖心情 Post By:2015/11/24 12:04:00 [只看该作者]

想对生成的临时表,金额小于0的行,标识为红色,代码要怎么写

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/24 12:18:00 [只看该作者]

Dim g = Tables("表A").Grid
Dim c As Integer = g.Cols("金额").Index
For i As Integer = 1 To g.Rows.count-1
    Dim r = g.Rows(i)
    If r(c).Gettype.name <> "DBNull" AndAlso r(c) < 0 Then
        Dim cs1 As C1.Win.C1FlexGrid.CellStyle = g.GetCellRange(r.index, c).style
        If cs1 Is Nothing Then
            cs1 = g.Styles.Add("样式1")
            g.SetCellStyle(r.index, c, cs1)
        End If
        cs1.backcolor = Color.Red
    End If
Next

 回到顶部
帅哥哟,离线,有人找我吗?
linswcfr
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:593 积分:5360 威望:0 精华:0 注册:2011/9/30 8:42:00
  发帖心情 Post By:2015/11/24 14:12:00 [只看该作者]

---------------------------
版本:2015.11.2.1
---------------------------
代码执行出错,错误信息:

 

System.InvalidCastException: 从字符串“金额”到类型“Double”的转换无效。 ---> System.FormatException: 输入字符串的格式不正确。

   在 Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)

   在 Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)

   --- 内部异常堆栈跟踪的结尾 ---

   在 Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)

   在 Microsoft.VisualBasic.CompilerServices.Operators.CompareObject2(Object Left, Object Right, Boolean TextCompare)

   在 Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectLess(Object Left, Object Right, Boolean TextCompare)

   在 UserCode.Test()
---------------------------
确定  
---------------------------

 

为什么会这有这个提示了


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/24 14:24:00 [只看该作者]

Dim g = Tables("表A").Grid
Dim c As Integer = g.Cols("金额").Index
For i As Integer = 1 To g.Rows.count-1
    Dim r = g.Rows(i)
    If r(c).Gettype.name <> "DBNull" AndAlso val(r(c)) < 0 Then
        Dim cs1 As C1.Win.C1FlexGrid.CellStyle = g.GetCellRange(r.index, c).style
        If cs1 Is Nothing Then
            cs1 = g.Styles.Add("样式1")
            g.SetCellStyle(r.index, c, cs1)
        End If
        cs1.backcolor = Color.Red
    End If
Next 

 回到顶部
帅哥哟,离线,有人找我吗?
linswcfr
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:593 积分:5360 威望:0 精华:0 注册:2011/9/30 8:42:00
  发帖心情 Post By:2015/11/24 14:28:00 [只看该作者]

要标识整行呢

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/24 14:32:00 [只看该作者]

Dim g = Tables("表A").Grid
Dim c As Integer = g.Cols("金额").Index
For i As Integer = 1 To g.Rows.count-1
    Dim r = g.Rows(i)
    If r(c).Gettype.name <> "DBNull" AndAlso val(r(c)) < 0 Then
        For Each gc As object In g.Cols
            Dim cs1 As C1.Win.C1FlexGrid.CellStyle = g.GetCellRange(r.index, gc.index).style
            If cs1 Is Nothing Then
                cs1 = g.Styles.Add("样式1")
                g.SetCellStyle(r.index, gc.index, cs1)
            End If
            cs1.backcolor = Color.Red
        Next
    End If
Next

 回到顶部
帅哥哟,离线,有人找我吗?
linswcfr
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:593 积分:5360 威望:0 精华:0 注册:2011/9/30 8:42:00
  发帖心情 Post By:2015/11/24 14:48:00 [只看该作者]

谢谢老师

 回到顶部