先上代码:
public class BindingCollection<T> : BindingList<T>
{
protected bool isSorted;
protected PropertyDescriptor sortProperty;
protected ListSortDirection sortDirection;
public ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 构造函数
/// </summary>
public BindingCollection()
: base()
{
}
public delegate void ApplySortCoreDel(PropertyDescriptor property, ListSortDirection direction);
/// <summary>
/// 自定义排序操作
/// </summary>
/// <param name="property"></param>
/// <param name="direction"></param>
protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
{
List<T> items =