What I needed was a way to easily get filtering and sorting working for the list of objects. I found 2 links that helped me out a ton. The first one is Building a Drop-Down Filter List for a DataGridView Column Header Cell. This article is incredibly well-written and talks about the different interfaces you need to implement, and provides a sample, too. For the sorting, I used Brian Noyes' BindingListView class from Chapter 9 of his excellent book, Data Binding with Windows Forms 2.0.
When stitching these 2 pieces together, I noticed several things:
string IBindingListView.Filter{ get { return m_FilterString; } set { if (string.IsNullOrEmpty(value)) ((IBindingListView)this).RemoveFilter(); else { m_FilterString = value; m_Filtered = true; UpdateFilter(); } }}
string IBindingListView.Filter
{
get
return m_FilterString;
}
set
if (string.IsNullOrEmpty(value))
((IBindingListView)this).RemoveFilter();
else
m_FilterString = value;
m_Filtered = true;
UpdateFilter();
By doing all of this, I got things working the way I wanted. Now it's time to tackle the next task of getting child objects bound properly in a DataGridView.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.