2

ApplySortCoreカスタム BindingList のメソッドを次のようにオーバーライドしました。

public void ApplySort(PropertyDescriptor prop, ListSortDirection direction)
{
    ApplySortCore(prop, direction);
}
protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction)
{
    sortedList = new System.Collections.ArrayList();
    Type interfaceType = prop.PropertyType.GetInterface("IComparable");

    if (interfaceType != null)
    {
        sortPropertyValue = prop;
        sortDirectionValue = direction;

        unsortedList = new System.Collections.ArrayList(this.Count);

        foreach (Object item in this.Items)
        {
            sortedList.Add(prop.GetValue(item));
            unsortedList.Add(item);
        }

        sortedList.Sort();
        isSortedValue = true;

        OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
    }
}

クラス レベルの PropertyDescriptor (クラス プロパティは InstanceName) を定義して、これを次のように直接呼び出すにはどうすればよいですか。

_filteredEntityTally.ApplySort( ???? ,ListSortDirection.Ascending);
4

1 に答える 1

2

これを見てください

List<T>.Sort() のように動作する BindingList<T>.Sort()

于 2011-02-08T05:08:11.847 に答える