首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为排序BindingList的PropertyDescriptor定义类级属性?

如何为排序BindingList的PropertyDescriptor定义类级属性?
EN

Stack Overflow用户
提问于 2011-02-08 11:09:08
回答 1查看 1.9K关注 0票数 2

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

代码语言:javascript
复制
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)来直接调用它,如下所示:

代码语言:javascript
复制
_filteredEntityTally.ApplySort( ???? ,ListSortDirection.Ascending);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-02-08 13:08:12

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4929200

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档