I have a radgridview that I want to change the background color of three columns depending on the value of the cells. The following code works great for changing the colors of the cells based on its value, however if i click into the cell all the formatting for that cell is lost. Is there something we are missing here?
Private Sub rgvTimeCards_CellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles rgvTimeCards.CellFormatting Dim amtIndex As Integer = rgvTimeCards.Columns("BillableAmount").Index Dim hrsIndex As Integer = rgvTimeCards.Columns("MarkUpHrs").Index Dim dollarsIndex As Integer = rgvTimeCards.Columns("MarkUpDollars").Index If e.CellElement.ColumnIndex.Equals(hrsIndex) Or e.CellElement.ColumnIndex.Equals(dollarsIndex) Then If rgvTimeCards.Rows(e.CellElement.RowIndex).Cells(e.CellElement.ColumnIndex).Value < 0 Then e.CellElement.NumberOfColors = 2 e.CellElement.BackColor = Color.White e.CellElement.BackColor2 = Color.Pink e.CellElement.ForeColor = Color.Black e.CellElement.DrawFill = True ElseIf rgvTimeCards.Rows(e.CellElement.RowIndex).Cells(e.CellElement.ColumnIndex).Value > 0 Then e.CellElement.NumberOfColors = 2 e.CellElement.BackColor = Color.White e.CellElement.BackColor2 = Color.FromArgb(219, 230, 145) e.CellElement.ForeColor = Color.Black e.CellElement.DrawFill = True Else e.CellElement.DrawFill = False End If ElseIf e.CellElement.ColumnIndex.Equals(amtIndex) Then If rgvTimeCards.Rows(e.CellElement.RowIndex).Cells(e.CellElement.ColumnIndex).Value < 0 Then e.CellElement.NumberOfColors = 2 e.CellElement.BackColor = Color.White e.CellElement.BackColor2 = Color.Pink e.CellElement.ForeColor = Color.Black e.CellElement.DrawFill = True Else e.CellElement.DrawFill = False End If End If End Sub