Если речь идет о TableWrapper, то для сортировки нужно добавить:
#region *** СОРТИРОВКА ***
/// <summary>
/// Gets a value indicating whether the list supports searching.
/// </summary>
/// <returns>
/// true if the list supports searching; otherwise, false. The default is false.
/// </returns>
protected override bool SupportsSearchingCore
{
get { return true; }
}
/// <summary>
/// Gets a value indicating whether the list supports sorting.
/// </summary>
/// <returns>
/// true if the list supports sorting; otherwise, false. The default is false.
/// </returns>
protected override bool SupportsSortingCore
{
get { return true; }
}
/// <summary>
/// Признак того, что есть сортировка
/// </summary>
private bool isSortedCore = false;
/// <summary>
/// Gets a value indicating whether the list is sorted.
/// </summary>
/// <returns>
/// true if the list is sorted; otherwise, false. The default is false.
/// </returns>
protected override bool IsSortedCore
{
get { return isSortedCore; }
}
/// <summary>
/// Направление сортировки
/// </summary>
private ListSortDirection sortDirectionCore = ListSortDirection.Ascending;
/// <summary>
/// Gets the direction the list is sorted.
/// </summary>
/// <returns>
/// One of the <see cref="T:System.ComponentModel.ListSortDirection" /> values. The default is <see cref="F:System.ComponentModel.ListSortDirection.Ascending" />.
/// </returns>
protected override ListSortDirection SortDirectionCore
{
get { return sortDirectionCore; }
}
/// <summary>
/// Свойство для сортировки
/// </summary>
private PropertyDescriptor sortPropertyCore = null;
/// <summary>
/// Gets the property descriptor that is used for sorting the list if sorting is implemented in a derived class; otherwise, returns null.
/// </summary>
/// <returns>
/// The <see cref="T:System.ComponentModel.PropertyDescriptor" /> used for sorting the list.
/// </returns>
protected override PropertyDescriptor SortPropertyCore
{
get { return sortPropertyCore; }
}
/// <summary>
/// Sorts the items if overridden in a derived class; otherwise, throws a <see cref="T:System.NotSupportedException" />.
/// </summary>
/// <param name="prop">A <see cref="T:System.ComponentModel.PropertyDescriptor" /> that specifies the property to sort on.</param>
/// <param name="direction">One of the <see cref="T:System.ComponentModel.ListSortDirection" /> values.</param>
/// <exception cref="T:System.NotSupportedException">Method is not overridden in a derived class. </exception>
protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction)
{
sortDirectionCore = direction;
sortPropertyCore = prop;
GenericSortComparer<IRow> comparer = new GenericSortComparer<IRow>(prop, direction);
List<IRow> listRef = this.Items as List<IRow>;
if (listRef != null)
{
listRef.Sort(comparer);
isSortedCore = true;
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
}
}
#endregion