2011-02-08 1 views
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); 
+0

を見てみましょう拡張メソッドまたは何か? –

+0

@Shekhar_Pro - BindingListにソートを適用したいだけです。ソートするプロパティを定義するPropertyDescriptorを渡す必要があります。 – wulfgarpro

答えて

関連する問題