I have a DataGridView which has been bound to a generic BindingList. I want to be able to apply sort and search on columns of type DataGridViewImageColumn. The basic idea is to store a name into the image Tag and use is for sorting and searching. How can I do that?
It seems several ways to do it:
- Creating a new class inheriting
System.Drawing.Imageand making it comparable.Imageis an abstract class and if I inherit from it (as well asIComparableinterface), I'll encounter with this error message: The type 'System.Drawing.Image' has no constructors defined. What's the problem here? Image is anabstractnot asealedclass, but it doesn't allow me to inherit it!
Using protected override
ApplySortCoremethod of inherited class fromBindingList<T>.This method is like so:
class MyBindingList<T> : BindingList<T> { ... protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction) { if (prop.PropertyType.Equals(typeof(Image))) { /* I have no idea! */ } } }
- Creating a new
DataGridViewColumninheriting fromDataGridViewImageColumn.- This doesn't seem to be easy and may be used if other ideas are unusable.
Thanks in advance
I found the way!
MyBindingList
MyDataObject
Form