Background Color spreads to other cells when scrolling

4 posts, 0 answers
  1. Gone2TheDogs
    Gone2TheDogs avatar
    65 posts
    Member since:
    May 2016

    Posted 18 Mar 2019 Link to this post

    I've looked at other posts, but I didn't see where I went wrong. 

    (review attached screenshot for a better understanding)

    In my situation, I add background color to row cells where this is an "A" value in the cell. This stands for an aisle in a warehouse.

    If you scroll slowly, then the background color stays within the rows with an "A", but if you scroll too fast, the display shows green in various cells. Also, if I clear the grid and rebuild it with new data, the background color is not reset. The previous rows that were green are still green.

    What am I missing?

    01.Private Sub dgvMain_CellFormatting(sender As Object, e As CellFormattingEventArgs) Handles dgvMain.CellFormatting
    02.    If _LeftOrRightConveyor = "LEFT" And e.CellElement.ColumnIndex = AisleColumnLeft_Idx Then
    03.        e.CellElement.BackColor = System.Drawing.Color.LightGreen
    04.    ElseIf _LeftOrRightConveyor = "RIGHT" And e.CellElement.ColumnIndex = AisleColumnRight_Idx Then
    05.        e.CellElement.BackColor = System.Drawing.Color.LightGreen
    06.    End If
    07. 
    08.    If e.CellElement.Value = "A" Then
    09.        e.CellElement.BackColor = System.Drawing.Color.Lime
    10.    End If
    11.End Sub
  2. Hristo
    Admin
    Hristo avatar
    1519 posts

    Posted 19 Mar 2019 Link to this post

    Hi,

    The RadGridView control is virtualized and the cell elements are being reused to show different data items. Detailed information on the UI virtualization is available here:
    Due to the virtualization, it is required to provide an Else clause in the formatting events so that the styles set on a cell element are reset when this element gets synchronized with a different data item. You can consider resetting the back color similarly as demonstrated here: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells.

    I hope this will help. Let me know if you need further assistance.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Gone2TheDogs
    Gone2TheDogs avatar
    65 posts
    Member since:
    May 2016

    Posted 19 Mar 2019 Link to this post

    Right there in the documentation in plain view. I appreciate your bringing it to my attention. 
  4. Hristo
    Admin
    Hristo avatar
    1519 posts

    Posted 20 Mar 2019 Link to this post

    Hello Bob,

    I am glad that I managed to help. Let me know if you need further assistance.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top