If you have not yet downloaded ObjectListView you should. Its available here:
It allows you to easily filter and sort business collections. A good example of where I use it is in populating a TreeView control. The problem with populating a treeview control is in populating the children.
Typically all children come from the same table but have a differnt parent id. ObjectListView makes it easy to filter the children collection by parent id and sort it. This filtered list is what is used to generate the appropreiate child notes on the tree for that parent id.
Filtering & sorting is so simple because out of the box you can filter by any public property exposed by the underlying BusinessList object.
Are there any alternatives to using ObjectListView that I don't know about to get a filtered & sorted view of an IList / BO?
Regards,
Rob Wheeldon
Maybe I'm using it wrong (and that's not unlikely!), but I don't really like using SortedBindingList.
In an unsorted form, I cache the collection object. That cached object is passed to the grid and it is also available for use in various events that I might raise in the form.
When I return a SortedBindingList instead of the object collection and cache it, I can pass it to the grid just fine. But it is useless for handling any object-specific events. At least it is to me, because I can't find a way to "un-cast" it back to the original object its sorting.
So, my questions are:
1) Does using ObjectListView have the same problem?
2) How could I use SortedBindingList so I don't have that problem? (Cache both the object collection and the sortedbindinglist?)
new
ObjectListView(Business.Accounts.GetAccounts(), "GroupID=" + accountGroupInfo.ID)This example is an overload with a filter passed in as the second parameter. You can filter and sort the OLV. It sounds like the 2.1 solution uses two differnt objects to accomplish this? SortedList & FilteredList(of t)?
The ObjectListView then subscribes to the BO list changed event:
_iBindingList = (
IBindingList)list;_iBindingList.ListChanged +=
new ListChangedEventHandler(_iBindingList_ListChanged);ObjectListView is now ready to use in you UI databinding and will raise an event when the business object changes. Subscribe to the OLV event from your UI control and implement the apropreiate refresh.
_list.ListChanged += new ListChangedEventHandler(_list_ListChanged);
As a specific example I use this event to update the nodes in a treeview based on the ListChangedEventArgs e class.
switch
(e.ListChangedType)Regards,
Rob Wheeldon
Copyright (c) Marimer LLC