Completed
Last Updated: 20 Jan 2015 15:46 by ADMIN
ADMIN
Dimitar
Created on: 23 Dec 2014 13:43
Category: PropertyGrid
Type: Bug Report
0
FIX. RadPropertyGrid - sorting 6000 items takes a lot of time.
To reproduce: 
private void PopulateGrid()
{
    this.radPropertyGrid1.SortOrder = System.Windows.Forms.SortOrder.Ascending;
    PropertyStoreItem myRadProp;
  
    RadPropertyStore myRadProperties = new RadPropertyStore();

    for (int i = 0; i <= 6000; i++)
    {

        myRadProp = new PropertyStoreItem(typeof(string), "PropName" + i, "Value" + i, "Help" + i, "same");

        myRadProperties.Add(myRadProp);
    }

    radPropertyGrid1.SelectedObject = myRadProperties;
}


Workaround:

public Form1()
{
    InitializeComponent();

    radPropertyGrid1.PropertyGridElement.PropertyTableElement.ListSource.CollectionView.GroupFactory =
        new MyPropertyGridGroupFactory(this.radPropertyGrid1.PropertyGridElement.PropertyTableElement);
    this.radPropertyGrid1.SortOrder = System.Windows.Forms.SortOrder.Ascending;
    PropertyStoreItem myRadProp;

    RadPropertyStore myRadProperties = new RadPropertyStore();

    for (int i = 0; i <= 6000; i++)
    {
        myRadProp = new PropertyStoreItem(typeof(string), "PropName" + i, "Value" + i, "Help" + i, "same");

        myRadProperties.Add(myRadProp);
    }
           
    this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.ListSource.BeginUpdate();
    radPropertyGrid1.SelectedObject = myRadProperties;
    this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.ListSource.EndUpdate();
}

public class MyPropertyGridGroupFactory : IGroupFactory<PropertyGridItem>
{
    private PropertyGridTableElement propertyGridElement;

    public MyPropertyGridGroupFactory(PropertyGridTableElement propertyGridElement)
    {
        this.propertyGridElement = propertyGridElement;
    }

    public GroupCollection<PropertyGridItem> CreateCollection(IList<Group<PropertyGridItem>> list)
    {
        return new PropertyGridGroupCollection(list);
    }

    public Group<PropertyGridItem> CreateGroup(object key, Group<PropertyGridItem> parent, params object[] metaData)
    {
        return new MyPropertyGridGroup(key, parent, this.propertyGridElement);
    }
}

public class MyPropertyGridGroup : PropertyGridGroup
{
    private List<PropertyGridItem> items;

    public MyPropertyGridGroup(object key, Group<PropertyGridItem> parent, 
        PropertyGridTableElement propertyGridElement) : base(key, parent, propertyGridElement)
    {
    }

    protected override IList<PropertyGridItem> Items
    {
        get
        {
            if (this.items == null)
            {
                this.items = new List<PropertyGridItem>();
            }

            return this.items;
        }
    }
}
0 comments