Dim myFont As Font
Select Case True
Case TypeOf e.CellElement Is GridGroupContentCellElement
'these are the group cells
'get the native font for the cell
myFont = e.CellElement.Font
If e.CellElement.Text.Contains("Yard") Then
'add 'bold' to the font, increase the font size
myFont = New Font(e.CellElement.Font.FontFamily, 10, FontStyle.Bold)
'color the cell
e.CellElement.ForeColor = Color.CornflowerBlue
Else
'increase the font size
myFont = New Font(e.CellElement.Font.FontFamily, 10, FontStyle.Regular)
e.CellElement.ForeColor = Color.Black
End If
e.CellElement.Font = myFont
e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid
e.CellElement.DrawFill = True
Case TypeOf e.CellElement Is GridDataCellElement
'gather data from the cells
Dim bCommercial As Boolean = e.CellElement.RowInfo.Cells("blnCommercialJob").Value
Dim dtRSD As Date = e.CellElement.RowInfo.Cells("ReqShipDate").Value
Dim bSetBackColor As Boolean = False
Dim bSetForeColor As Boolean = False
'business logic
If DateAdd(DateInterval.Day, -7, dtRSD) < Now Then
bSetBackColor = True
End If
If bCommercial Then
bSetForeColor = True
End If
If bSetBackColor Or bSetForeColor Then
If bSetBackColor Then
e.CellElement.BackColor = Color.Beige
Else
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
End If
If bSetForeColor Then
e.CellElement.ForeColor = Color.Maroon
Else
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
End If
e.CellElement.DrawFill = True
e.CellElement.NumberOfColors = 1
Else
'reset the values if this cell is not subject to our business logic
e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
End If
'selectively enable/disable a command column
If e.CellElement.ColumnInfo.Name.ToUpper = "CMDRELEASE" Then
If e.CellElement.Value = "" Or App.IsSalesperson Then
e.CellElement.Enabled = False
Else
e.CellElement.Enabled = True
End If
End If
Case TypeOf e.CellElement Is GridHeaderCellElement
'format header cells here
Case Else
'placekeeper
End Select