cancel
Showing results for 
Search instead for 
Did you mean: 

Color Cells in Grid - Very Slow

sawsine
Participant
0 Kudos
126

I have a user form with a grid containing 2000 rows,

When the data is loaded certain Cells need to be colored either Red or Green depending on their value.

The performance is absolutely abysmal (takes about 30 seconds to load )

the code I am using is as follows:

  Private Sub colorAllPlanQtyRows()   

            For i = 0 To planGrid.Rows.Count - 1
                planGrid.CommonSetting.SetCellFontColor(i + 1, 11, getPlanQuantityValidationColour(i))
            Next

        End Sub

  Private Function getPlanQuantityValidationColour(row As Integer) As Integer

            Dim reqQty As Integer = dtPlan.GetValue("RequiredQuantity", planGrid.GetDataTableRowIndex(row))
            Dim planQty As Integer = dtPlan.GetValue("PlanQuantity", planGrid.GetDataTableRowIndex(row)) 

            If planQty < reqQty Then
                Return red
            Else
                Return green
            End If

        End Function

Are there any alternative methods for coloring multiple cells without the overhead of looping the entire grid?

Thank you

Accepted Solutions (0)

Answers (0)