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;
}
}