Expand/collapse icons turn up where not expected

2 posts, 0 answers
  1. Johan
    Johan avatar
    2 posts
    Member since:
    Feb 2013

    Posted 21 Feb 2013 Link to this post

    In my RadGridView I have a comumn containing expand/collapse icons for some rows to drill down into referenced data. Sometimes when scrolling around the GUI these + and - icons start showing up in other columns were they are not expected. I guess something should be reset when drawin the graphics in the CellFormatting event, but what?

  2. Plamen
    Plamen avatar
    132 posts

    Posted 26 Feb 2013 Link to this post

    Hello Johan,

    Thank you for writing.

    RadGridView control uses virtualization for its cells and rows. Due to this virtualization in RadGridView, cell elements are created only for the currently visible cells and are being reused during operations like scrolling, filtering, grouping and so on.

    If you want to prevent applying the formatting to other columns' cell elements (because of the cell reuse) all customizations should be reset for the rest of the cell elements. Here is a sample code snippet, which implements this functionality:
    void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
        if (e.CellElement.ColumnInfo.Name == "ImageColumn")
            if (e.Row.IsExpanded)
                e.CellElement.Image = Resources.PlusSign;
                e.CellElement.Image = Resources.MinusSign;
            // Reset specific property
            e.CellElement.ResetValue(LightVisualElement.ImageProperty, ValueResetFlags.Local);

    Additionally, you could take a look at our documentation articles about:

    I hope this helps.

    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top