In some case when we load data from database to grid, we want to change backcolor/forecolor on some cell depends by its value. like this pic below:
Change cell backcolor/forecolor based by cell value |
Imports DevExpress.XtraGrid.Views.Grid
'-----
Dim View As GridView = sender
If e.Column.FieldName = "slsh_Keluar" Then
Dim _sklrVal As Integer = View.GetRowCellValue(e.RowHandle, View.Columns("slsh_Keluar"))
If _sklrVal <> 0 Then
e.Appearance.BackColor = Color.Red
e.Appearance.ForeColor = Color.Yellow
'e.Appearance.BackColor2 = Color.Yellow
End If
End If
If e.Column.FieldName = "slsh_masuk" Then
Dim _smskVal As Integer = View.GetRowCellValue(e.RowHandle, View.Columns("slsh_masuk"))
If _smskVal <> 0 Then
e.Appearance.BackColor = Color.Red
e.Appearance.ForeColor = Color.Yellow
End If
End If
Good Luck..
itu naro kodingnya dimana bos ?
ReplyDelete