c# - 如何为 PropertyDescriptor 定义类级属性以对 BindingList 进行排序?

标签 c# overriding bindinglist

我已经覆盖了自定义 BindingList 的 ApplySortCore 方法,如下所示:

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

最佳答案

关于c# - 如何为 PropertyDescriptor 定义类级属性以对 BindingList 进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4929200/

相关文章:

scala - 为什么在 scala 中不能覆盖可变变量?

c# - IBindingList 更改通知

c# - worker线程加入BindingList时跨线程操作异常

c# - 有关硬件 ID 的帮助

c# - 删除其他表中没有引用的行

JavaScript 覆盖方法

java - 如何根据条件重写方法

c# - 组合框数据源不创建项目

c# - 流式下载的 WCF 最佳实践/配置

c# - 在 JSON 通用属性序列化中包含类名