1
私はそうのようなカスタムするBindingListためApplySortCore
メソッドをオーバーライドしていますBindingListをソートするためのPropertyDescriptorにクラスレベルのプロパティを定義する方法は?
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));
}
}
は、どのように私は直接そのようにこれを呼び出すために(クラスのプロパティがInstanceNameにある)クラスレベルのPropertyDescriptorを定義することができます。
_filteredEntityTally.ApplySort(???? ,ListSortDirection.Ascending);
を見てみましょう拡張メソッドまたは何か? –
@Shekhar_Pro - BindingListにソートを適用したいだけです。ソートするプロパティを定義するPropertyDescriptorを渡す必要があります。 – wulfgarpro