473,396 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Filtering with BindingList

Hello All

I'm trying to use a filter with collectiong derived off BindingList
and I see that if I use the foreach way of adding and checking the
item then I get instant feedback on the grid. If I use a Predicate to
filter using FindAll then I see my grid refreshed only when I change
the selected row.

My class is defined as this ....

public class BindingListView<T: BindingList<T>, IBindingListView

Basically I'm getting the criteria and then doing this in
UpdateFilter:

int equalPos = m_FilterString.IndexOf('=');
string propName = m_FilterString.Substring(0, equalPos).Trim();
string criteria = m_FilterString.Substring(equalPos + 1,
m_FilterString.Length - equalPos - 1).Trim();
criteria = criteria.Substring(1, criteria.Length - 2); // string
leading and trailing quotes

//Get a property descriptor for the filter property
PropertyDescriptor propDesc = TypeDescriptor.GetProperties(typeof(T))
[propName];
if (m_OriginalColl.Count == 0)
m_OriginalColl.AddRange(this);

//Make a List object from current collection
List<TcurrentColl = new List<T>(this);
Clear();

/*** This commented part gives instant feedback on the grid
//foreach (T item in currentColl)
//{
// object val = propDesc.GetValue(item);
// if (val.ToString().Trim() == criteria)
// {
// Add(item);
// }
//}

//*** This needs manual changes to row to update the grid
((List<T>)Items).AddRange(currentColl.FindAll(GetP redicateDelegate(propDesc,
criteria)));

Where this returns the predicate

private Predicate<TGetPredicateDelegate(PropertyDescriptor prop,
object key)
{
Predicate<Tpred = delegate(T item)
{
if (prop.GetValue(item).Equals(key))
return true;
else
return false;
};
return pred;
}

Any hints are appreciated.

thanks
Sunit

Sep 24 '07 #1
0 1608

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

Similar topics

4
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...
1
by: Dave Booker | last post by:
Is there a reason why the BindingList constructor doesn't create a new BindingList? Create a form with four ListBoxes and the following will result in them all containing the exact same thing. ...
1
by: Pieter | last post by:
Hi, I have a custom List that inherits from BindingList. It has some methods overloaded, like the Add/Insert/etc to add and remove some eventhandlers when adding or removing an item T of the...
3
by: Bryan | last post by:
I am calling BindingList.EndEdit during a 'TextChanged' sub for a texbox. In theory, the key should be pressed changing the value in the text box, the EndEdit call should append the changes to the...
5
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...
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
6
by: jwilson128 | last post by:
I am trying to decide whether to use a system.ComponentModel.BindingList(of T) or a Sytem.Collections.Generic.List(of T) for a custom collection. In testing a simple, read-only data binding to a...
1
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I have a ComboBox named comboBoxSelChannel. I declared a structure named MySturct. public struct MyStruct { public int Index; public string Name;
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.