473,947 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingList<T> and .FindAll()

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).

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<Tin stance (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!
Dec 11 '06 #1
1 4453

"Merk" <A@B.COMwrote in message
news:Oh******** ******@TK2MSFTN GP03.phx.gbl...
>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<fo r each
subset, and a IBindingList<fo r 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<Tin stance (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!

Dec 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5467
by: Frank VDL | last post by:
Hi, To be able to show my objects in a Grid, I've inherited my list implementation from BindingList<T>. The problem is that de objects in this list are created/changed/deleted in different threads. If I link the BindingList<T> implementation to a grid (grdNodes.DataSource = Nodes.List), I get a thread exception when I try to add a new object using a worker thread.
4
3533
by: hazz | last post by:
The data access layer below returns, well, a mess as you can see on the last line of this posting. What is the best way to return customer objects via a datareader from the data layer into my view and bind them to a datagrid using BindingList. I am in need of an epiphany here. Thank you. -Greg ******************BIND ARRAY OF CUSTOMER OBJECTS TO DATAGRID ************************ private Customer c; c =...
0
1544
by: Chris Dunaway | last post by:
I posted this to the xml group but got no responses, so I thought I'd try here. I have the following small class which inherits from the generic List class: public class FoodItemList : BindingList<FoodItem> { private bool _hasChanges = false;
0
1318
by: AndyM | last post by:
I have tried to create an object that is a binding list where the value of T varies and so cannot be hard coded. I used the override for CreateInstance which takes a type object. The Type was created using Type.GetType(string). The string was formed as follows. string collTypeName = string.Format( "System.ComponentModel.BindingList`1]", className, _omAssembly.FullName); Type collectionType = Type.GetType(collTypeName); _newCollection =...
5
7600
by: Mike Surcouf | last post by:
Hi All I have a stored procedure wrapper that returns Collection<T>. The wrapper is generated by codesmith so I don't really want to start altering it. I need to use this collection in a datagridview. I would like the ability to add to this collection or delete from this collection using the grid. I know I will need to use Bindinglist<T> for this but I don't seem to be able to cast from
4
5376
by: Michel Walsh | last post by:
Hi, A datagrid has its DataSource set to a BindingList<CustomClass>. While the ListChanged event fires AFTER a deletion, I am looking for a simple way to be notified BEFORE the item would be effectively deleted (for performing extra check and cleanup). Is there a simple trick I miss, because I don't know how to do that, except to maintain TWO lists, and compare them in the ListChanged event (to detect which item is now missing). ...
2
1905
by: csharpula csharp | last post by:
Hello, I would like to know what is better for data binding and serialization purposes ArrayList or List<? Thank you! *** Sent via Developersdex http://www.developersdex.com ***
1
4867
by: jehugaleahsa | last post by:
Hello: I would like to perform an action on an item when it is removed from a BindingList<T>. However, I can only find out how to get the old index of the item, which doesn't really help me. Is there a way to get at the removed item? Thanks, Travis
3
9712
by: jehugaleahsa | last post by:
Hello: I am binding a DataGridView with a BindingList<T>, where T is a custom business object that implements INotifyPropertyChanged. When you bind a DataGridView to a DataTable, it has this cool little feature - it will not call DataTable.Rows.Add until after you leave the DataGridView row. This is cool because it lets your user edit the record as much as needed to get it into a valid state before actually adding it to the DataTable.
0
9982
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11343
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10689
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6331
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3541
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.