I need to format the background color of the Summary row based on its Aggregated (Sum) value compared to another value on the form. If the values are equal, I want it blue, if they are not equal, I need it to be red.
Dim ugRow As GridViewRowInfo
Dim dAdditionTotal As Double = 0
For Each ugRow In radGVBuildingAdditions.Rows
dAdditionTotal += ugRow.Cells("Addition_SQFT").Value
Next
With Me.radGVBuildingAdditions.SummaryRowsBottom
If .Count > 0 Then
For i As Integer = 0 To .Count - 1
.Remove(.Item(i))
Next i
End If
End With
If dAdditionTotal > 0 Then
Dim summary1 As New GridViewSummaryItem()
summary1.Name = "Addition_SqFt"
summary1.Aggregate = GridAggregateFunction.Sum
summary1.FormatString = "Addition Total SF {0:#,##0}"
Dim summaryRowItem As New GridViewSummaryRowItem()
summaryRowItem.Add(summary1)
Me.radGVBuildingAdditions.SummaryRowsBottom.Add(summaryRowItem)
Me.radGVBuildingAdditions.MasterTemplate.ShowTotals = True
Me.radGVBuildingAdditions.MasterView.SummaryRows(0).IsVisible = True
Dim dBuildingArea As Double = IIf(CLIB_MAPPS.Utilities.ConvertNULLtoDouble(Me.txtBldgNetSF.Text) > 0, CLIB_MAPPS.Utilities.ConvertNULLtoDouble(Me.txtBldgNetSF.Text), Me.txtBldgEstimatedSF.Text)
If dAdditionTotal = dBuildingArea Then ' dBuildingArea from another control on the form
'MAKE SUMMARY ROW (NOT CELL, ENTIRE ROW) BLUE
Else
'MAKE SUMMARY ROW (NOT CELL, ENTIRE ROW) RED
End If
Else
Me.radGVBuildingAdditions.MasterTemplate.ShowTotals = False
End If
I attempted to do it in the ViewCellFormatting event, but this requires parsing the number back out of the formatted text and is only working with the Cell in which I placed the total.
Private Sub radGVBuildingAdditions_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs) Handles radGVBuildingAdditions.ViewCellFormatting
If TypeOf e.CellElement Is GridSummaryCellElement Then
Dim dArea As Double = IIf(CLIB_MAPPS.Utilities.ConvertNULLtoDouble(Me.txtBldgNetSF.Text) > 0, CLIB_MAPPS.Utilities.ConvertNULLtoDouble(Me.txtBldgNetSF.Text), Me.txtBldgEstimatedSF.Text)
If e.CellElement.ColumnInfo.Name = "Addition_SqFt" Then
If dArea = CInt(e.CellElement.Value) Then 'I HAVE TO PARSE THE TOTAL BACK OUT OF e.CellElement.Value
e.CellElement.BackColor = Color.DodgerBlue
Else
e.CellElement.BackColor = Color.Firebrick
End If
End If
End If
End Sub
is there a better way to do this?