This is a migrated thread and some comments may be shown as answers.

Expand/collapse icons turn up where not expected

1 Answer 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 21 Feb 2013, 02:53 PM
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?

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 26 Feb 2013, 09:41 AM
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;
        }
        else
        {
            e.CellElement.Image = Resources.MinusSign;
        }
    }
    else
    {
        // 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.

Regards,
Plamen
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
GridView
Asked by
Johan
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or