Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
925
Change row colour based on Field value
posted

I want to change the colour of rows in grid based on the flag value in a field.  I have atleast 300 000 rows! this means that the following is not going to do the trick.

for a = 0 to UltraGrid.Rows.Count - 1  

   if Ultragrid.ActiveRow.Cells("Flag_Done").Value = "True"      

             Ultragrid.ActiveRow.Appearance.BackColor = Color.LightGreen  

  else      

            Ultragrid.ActiveRow.Appearance.BackColor = Color.white  

endif  

next

 

How can a pre-paint the rows.  The above takes to long, VERY slow

Parents
  • 23930
    Suggested Answer
    Offline posted

    Hi Marius,

    Thank you for contacting Infragistics Developer Support.

    What you could do if you want to change the row color based on some value is to use the InitializeRow event. The event passes you the row and you can examine the values of any cell in that row. Based on those values, you can set the Appearance on the row or any cell in that row. To do this you can use code like:

    If CBool(e.Row.GetCellValue(e.Row.Band.Columns("Flag_Done"))) Then

                   e.Row.Appearance = flagDoneApp

    Else

                   e.Row.Appearance = flagDoneApp

    End If

    Also please note that it’s better if you re-use the appearance objects and not set them directly. For more information please visit this link:

    http://help.infragistics.com/Doc/WinForms/2013.2/CLR4.0/?page=WinGrid_Memory_Usage.html

    I am looking forward to your reply.

Reply Children