Completed
Last Updated: 01 Oct 2014 12:58 by ADMIN
ADMIN
George
Created on: 24 Mar 2014 12:46
Category: GridView
Type: Bug Report
0
FIX. RadGridView - Memory leak caused by PagingPanelElement.
To reproduce:


Create a form and add a timer with interval of 1 second and in tick handler do the following:


void t_Tick(object sender, EventArgs e)
{
    if (this.Controls.Count > 0)
    {
        Control oldGrid = this.Controls[0];
        this.Controls.RemoveAt(0);
        oldGrid.Dispose();




        GC.Collect(3, GCCollectionMode.Forced);
    }




    RadGridView grid = new RadGridView();
    grid.Dock = DockStyle.Fill;
    this.Controls.Add(grid);
}


You will see that the memory consumption will grow.


Workaround:


Use the following custom RadGridView


public class MyRadGridView : RadGridView
{
    protected override RadGridViewElement CreateGridViewElement()
    {
        return new MyElement();
    }
}


public class MyElement : RadGridViewElement
{
    protected override PagingPanelElement CreatePagingPanelElement()
    {
        return new MyPagingPanel();
    }


    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadGridViewElement);
        }
    }
}


public class MyPagingPanel : PagingPanelElement
{
    protected override void CreateButtonsStripElementChildElements()
    {
        base.CreateButtonsStripElementChildElements();


        this.ButtonsStripElement.Children.Add(this.ButtonsStripElement.Grip);
        this.ButtonsStripElement.Children.Add(this.ButtonsStripElement.OverflowButton);


        this.ButtonsStripElement.Grip.Visibility = this.ButtonsStripElement.OverflowButton.Visibility = ElementVisibility.Collapsed;
    }


    protected override void CreateTextBoxStripElementChildElements()
    {
        base.CreateTextBoxStripElementChildElements();


        this.TextBoxStripElement.Children.Add(this.TextBoxStripElement.Grip);
        this.TextBoxStripElement.Children.Add(this.TextBoxStripElement.OverflowButton);


        this.TextBoxStripElement.Grip.Visibility = this.TextBoxStripElement.OverflowButton.Visibility = ElementVisibility.Collapsed;
    }
}
0 comments