"Merk" <(E-Mail Removed)> wrote in message
news:OhT$(E-Mail Removed)...
>I need to show users a list of "Person" attributes in a grid. I currently
>have a custom "Person" class that mostly has a bunch of string properties
>(firstName, lastName, etc).
>
> While I want to have a collection of [a few hundred] Person objects behind
> the scenes, I want for only a specific subset to appear in the grid at any
> given time. The subset would be determined by rules such as (ID Number
> Between 100 and 130, or lastName begins with "SCH"), and the user will
> control which rule is in effect (i.e., user can specify which subset
> appears in the grid).
Is the number of rules small? You could use a IBindingList<> for each
subset, and a IBindingList<> for the main list. Then, subscribe each subset
list to the main list ListChanged event. When an item is added or removed
from the main list, test if it meets the criteria for the subset, then
add/remove it from the subset. This will make your iterative search
operations tend to be proportional to the subset size instead of the full
list length.
Also consider using a sorted list, linked list, or hashtable and
implementing IBindingList<> on top instead of using the default
BindingList<>.
>
> How would you go about implementing the above? I went in the direction of
> the following, but it seems overly complicated.
>
> So I was thinking to have two collections - one for all Person objects
> (lstAll), and another collection for the currently viewed subset
> (lstCurrent). My intention was to have lstAll be an instance of the
> generic .List<T> - but for lstCurrent to be a BindingList<T> instance (and
> bound to the grid). I wanted to somehow use the FindAll method of lstAll
> (a List<T>) to get references to the requisite Person objects into
> lstCurrent (a BindingList<T>). But I'd prefer to do this without looping
> if there is a faster way. Speed is important especially as the size of
> lstAll grows.
>
> I'd appreciate any recommendations for how to proceed. I'm feeling "in a
> bit over my head" at this point.
>
> Thanks!
>
|