I am trying to use the FilteredBindingList on one of my BusinessObjects that inherits from ReadOnlyListBase. However, once I have created the FilteredBindingList the SupportsSorting property returns false also when the same object is loaded into a SortedBindingList the SupportsSorting property is true.
ProductSearchResultList
products = ProductSearchResultList.GetProductSearchResultList("monitor");FilteredBindingList<ProductSearchResultInfo> filtered = new FilteredBindingList<ProductSearchResultInfo>(products);
bool test = filtered.SupportsSorting;
SortedBindingList<ProductSearchResultInfo> sorted = new SortedBindingList<ProductSearchResultInfo>(products);
bool test2 = sorted.SupportsSorting;
The example code above will return false for "test" and true for "test2". Since both the FilteredBindingList and the SortedBindingList use an IBindingList to return the SupportsSorting property I am a little confused as to why I am getting different behaviour.
ProductSearchResultList products = ProductSearchResultList.GetProductSearchResultList("monitor");
FilteredBindingList<ProductSearchResultInfo> filtered = new FilteredBindingList<ProductSearchResultInfo>(products);
bool test = filtered.SupportsSorting;
SortedBindingList<ProductSearchResultInfo> sorted = new SortedBindingList<ProductSearchResultInfo>(filtered);
bool test2 = sorted.SupportsSorting;
I see what you are saying and I also found that somewhere else after making the post.
Does raise the question of why the FilteredBindingList.ApplySort method is public if it is not useable?
ProductSearchResultList products = ProductSearchResultList.GetProductSearchResultList("monitor");
SortedBindingList<ProductSearchResultInfo> sorted = new SortedBindingList<ProductSearchResultInfo>(products);
bool test2 = sorted.SupportsSorting;
FilteredBindingList<ProductSearchResultInfo> filtered = new FilteredBindingList<ProductSearchResultInfo>(sorted);
bool test = filtered.SupportsSorting;
ajj3085:Actually, I think it throws an InvalidOperationException or something like that if you call ApplySort and AllowSort is false. If it doesn't, it probably should.
I'm pretty sure I got such an exception when trying to add to a list and AllowNew was false.
I always delegate the call - relying on the underlying implementation to throw any exceptions - unless the original list isn't an IBindingList, in which case I throw an exception directly.
Thanks all, I think its clearly now.....
The FilteredBindingList cannot perform sorting unless it has been constructed from a SortedBindingList.
Cheers
RockfordLhotka:I always delegate the call - relying on the underlying implementation to throw any exceptions - unless the original list isn't an IBindingList, in which case I throw an exception directly.
Copyright (c) Marimer LLC