我使用的是True DBgrid 6.0元件,做法如下: grdDataGrid是控制項的名稱 FetchCellStyle是控制項的方法Private Sub grdDataGrid_FetchCellStyle(ByVal Condition As Integer, ByVal Split As Integer, Book As Variant, ByVal Col As Integer, ByVal CellStyle As TrueDBGrid60.StyleDisp) With grdDataGrid If .Columns(Col).CellText(Book) = "5" Then CellStyle.BackColor = RGB(255, 255, 0) End If If .Columns(Col).CellText(Book) = "6" Then CellStyle.BackColor = RGB(0, 255, 255) End If If .Columns(Col).CellText(Book) = "7" Then CellStyle.BackColor = RGB(255, 0, 255) End If End With End Sub 希望對你有幫助
我在网上查资料,说可以用子类化,可是我看了半天,也没有搞定。
http://hi.baidu.com/starwork/blog/ITem/c4a274a7bd944694d043584b.HTML
grdDataGrid是控制項的名稱
FetchCellStyle是控制項的方法Private Sub grdDataGrid_FetchCellStyle(ByVal Condition As Integer, ByVal Split As Integer, Book As Variant, ByVal Col As Integer, ByVal CellStyle As TrueDBGrid60.StyleDisp)
With grdDataGrid
If .Columns(Col).CellText(Book) = "5" Then
CellStyle.BackColor = RGB(255, 255, 0)
End If
If .Columns(Col).CellText(Book) = "6" Then
CellStyle.BackColor = RGB(0, 255, 255)
End If
If .Columns(Col).CellText(Book) = "7" Then
CellStyle.BackColor = RGB(255, 0, 255)
End If
End With
End Sub
希望對你有幫助
那位帮帮忙阿!
http://topic.csdn.net/u/20090608/09/fd8b3f5a-59cb-40c5-8dac-484f29fdc2ec.html