I have a Devexpress gridview. I need to change the color of the entire row based on certain values in multiple columns. I have a category column, onHand column and a TrackLevel column. The colors are set out as below:
Stock Item with stock Track Levels on: White
Stock item no stock track levels on: Pienk/maroon/red (depending on screen quality)
Service item track levels off: Blue – if category is marked as service
Service item track levels on: Pienk/maroon/red (depending on screen quality) – if category is marked as service
Service item track levels off: Pienk/maroon/red (depending on screen quality) – if category is not marked as service
Grouped stock item: Green
Stock item track levels off: Yellow
I can use the Devexpress Designer but it does not allow me to evaluate the values of multiple columns.
I have visited https://supportcenter.devexpress.com/ticket/details/t621755/change-the-color-of-a-row-or-cell but there is no RowStyleEventArgs when I type it.
I handled the gridview.rowstyle event and it worked. Example code below:
Private Sub MyGridView_RowStyle(ByVal sender As Object, ByVal e As RowStyleEventArgs) Handles GridView1.RowStyle
Dim category As Integer = Convert.ToInt32(GridView1.GetRowCellValue(e.RowHandle, "CategoryID"))
If category = 1 Then
e.Appearance.BackColor = Color.Red
Else
e.Appearance.BackColor = Color.LightGreen
End If
e.HighPriority = True 'override any other formatting
End Sub