如何在True DBGrid Pro 7.0中将行的背景色设置成间隔的不同颜色?如何根据行中某个字段的值来决定本行的背景色?

解决方案 »

  1.   

    1. splits(x).AlternatingRowStyle=true,然后设置OddRowStyle和EvenRowStyle的BackColor2. splits(x).Columns(y).fetchstyle=true,然后响应FetchCellStyle事件,设置CellStyle的背景颜色。
      

  2.   

    2. splits(x).Columns(y).fetchstyle=true,然后响应FetchCellStyle事件,设置CellStyle的背景颜色。能说得再详细点吗?
      

  3.   

    先在form load中加入
    Dim st As Style
    Set st = grdPT.Styles.Add("TEST")
    With st
        .Parent = "Normal"
        .Font.Bold = True
        .BackColor = vbWhite
        .ForeColor = vbBlack
    End With
    Set st = grdPT.Styles.Add("SP")
    With st
        .Parent = "Normal"
        .Font.Bold = True
        .BackColor = &HC0FFC0
        .ForeColor = vbBlack
    End With
    Set st = grdPT.Styles.Add("WA")
    With st
        .Parent = "Normal"
        .Font.Bold = True
        .BackColor = &HC0C0FF
        .ForeColor = vbBlack
    End With
    Set st = grdPT.Styles.Add("red")
    With st
         .Parent = "normal"
         .Font.Bold = True
         .BackColor = &HFF8080
         .ForeColor = &H80000018
    End With
    Set st = grdPT.Styles.Add("ok")
        With st
        .Parent = "normal"
        .Font.Bold = True
        .BackColor = &HFFC0C0
        .ForeColor = vbBlack
        End With
         grdPT.FetchRowStyle = True
      

  4.   

    再加入
    Private Sub grdpt_FetchRowStyle(ByVal Split As Integer, Book As Variant, ByVal RowStyle As TrueOleDBGrid70.StyleDisp)
    Dim a As String
    If Trim(grdPT.Columns("某个字段").CellText(Book)) = "某个内容" Then
          RowStyle = "red"
        End If
     If Trim(grdPT.Columns("某个字段").CellText(Book)) = "某个内容" Then
            RowStyle = "test"
        End If
        If Trim(grdPT.Columns("某个字段").CellText(Book)) = "某个内容" Then
           RowStyle = "wa"
           End If
            If Trim(grdPT.Columns("某个字段").CellText(Book)) = "某个内容" Then
           RowStyle = "sp"
           End If
            If Trim(grdPT.Columns("某个字段").CellText(Book)) = "某个内容" Then
           RowStyle = "ok"
           End If
        
    End Sub