.net Value Class sorting with IComparable
- by greggorob64
I'm running into an issue using a DataGridView bound to a iBindingListView implementation (third party dll) attached to a large collection.
There's a certain property in my collection type, named MyDateTime, which is a value class similar to DateTime, but also with some legacy code.
This VALUE CLASS implements iComparable, iComparable<T>, and iEquatable<T>.
The issue I'm having is this:
When I apply a sort to the iBindingListView, or the Automatic Sorting provided by the DGV on the MyDateTimeColumn, it ALWAYS uses the non-generic iComparer, causing hundreds of thousands of unnecessary boxing and unboxing.
When I remove the non-generic iComparer, the generic one is still not used, it just does a string compare on the .ToString().
Am I missing something? Why is my generic comparer not bieng called on a sort?