Updating large list instantly - Datagridview vs. Listview vs. ???

Chris Hollman

Member
Joined
Nov 1, 2011
Messages
9
Location
Rome, New York, United States
Programming Experience
5-10
Hello, this is my first post here, I registered because I have a problem and I was wondering if anyone here would have a good idea to help me.

What I am trying to do is to instantly apply a filter to a large list of data such that the list is updated almost immediately regardless of the number of items in the list. I have this working using a listview right now but it is far from instant, a list of 5000 items takes over a minute to get through. What I do currently is to maintain a cache of my data that my listview entries are based on. When the user selects a filter I parse this data one item at a time and determine if each item should still be displayed in the listview, if not I remove it. The complexity of determining whether or not a data entry meets the filter requirements is O(1), but just getting through each element in a loop takes significant time, and so does updating the list view graphically at the end of the process.

I have considered using a datagridview instead, using a database connection. I have never done this before and my main question here is whether this would allow me to do what I have described. With the database I could form an SQL query to return only the items that meet the new filter requirements... but would the data in the form update immediately, or would there still be significant delay?

Alternatively, if anyone has any other ideas I would love to hear them. If you need more information let me know. Thanks.
 
If you use a database/dataset, you should be able to set a filter on the datasource (if the underlying list implements the IBindingListView interface, which the DataSet does). For example, if you use a BindingSource, you can set it's Filter property (the string filter will be similar to an SQL where clause, with the WHERE word, for instance: "Title='SomeTitle'"). I would think that 5,000 items would be filtered very quickly using this method.
 
Back
Top