I have a DataGridView that is displaying a List of objects (not DataSet). Is there an easy way to set a filter, so the DGV will only display rows that match the filter?
IList<T> log = ...; dgv.DataSource = log;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you have LINQ available? If so, one option is:
However, new/removed rows won’t update the original list (edits to existing rows are fine).
If not LINQ, you can do the same with
List<T>.FindAll:There is the
IBindingListView.SupportsFiltering/IBindingListView.Filterpair, but none of the standard lists (includingBindingList<T>) implement this feature.