Foxtable(狐表)用户栏目专家坐堂 → 单元格标色


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

主题:单元格标色

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/13 11:08:00 [只看该作者]

If e.Row.IsNull(e.Col.Name) = False Then
    e.StartDraw()
    Dim cval As String = e.Row(e.Col.Name)
    e.text = ""
    Dim arr() As String = cval.Split(",")
    Dim lst As new List(of String)
    Dim g As Graphics = e.Graphics
    Dim fnt = New Font("微软雅黑", e.Table.Font.Size)
   
    For Each s As String In arr
        Dim h As String =  IIF(s.Contains("(已)"),"$$",IIF(s.Contains("(未)"),"@$",""))
        s = s.Replace("(已)", "").Replace("(未)", "")
        Dim w1 As Integer = g.MeasureString(s, e.Table.Font).Width
        If w1 > e.Width
            Dim k1 As Integer = Math.Floor(s.Length * ( e.Width / w1))
            Dim i2 As Integer = 0
            Do While i2 < s.Length
                Dim s2 As String = ""
                If i2+k1<s.Length-1
                    s2 = s.SubString(i2,k1)
                Else
                    s2 = s.SubString(i2)
                End If
                i2 = i2+k1
                lst.Add(h & s2)
                Exit For
            Loop
        Else
            lst.Add(h & s)
        End If
    Next
    Dim x As Integer = e.x + 1
    Dim y As Integer = e.Y + 1
    Dim idx As Integer = 0
    Dim h1 As Integer = g.MeasureString("A", e.Table.Font).Height
    For Each s As String In lst
        If y + h1 > e.y + 1 + e.height Then
            '超过行高
        Else
            If s.StartsWith("$$") Then
                g.DrawString(s.SubString(2), e.Table.Font, Brushes.Gray, e.x, y)
            ElseIf s.StartsWith("@$") Then
                g.DrawString(s.SubString(2), e.Table.Font, Brushes.Blue, e.x, y)
            Else
                g.DrawString(s, e.Table.Font, Brushes.Black, e.x, y)
            End If
        End If
        y = y + h1 + 1
    Next
End If

 回到顶部
总数 21 上一页 1 2 3