RobinS,
Assuming that TEntity is a class, here's an example of what you need to
do. This code goes in the class that is the BindingList<TEntity>.
Thank you. I have custom Combobox cell in DataGridView
class ComboBoxCell : DataGridViewComboBoxCell {
protected override object GetFormattedValue(object value,
int rowIndex, ref DataGridViewCellStyle cellStyle,
TypeConverter valueTypeConverter,
TypeConverter formattedValueTypeConverter,
DataGridViewDataErrorContexts context) {
.....
return base.GetFormattedValue(value, rowIndex, ref cellStyle,
valueTypeConverter, formattedValueTypeConverter, context);
}
Using your class causes exception when form is opened in
base.GetFormattedValue()
System.NotSupportedException was unhandled
Message="Specified method is not supported."
Source="System"
StackTrace:
at System.ComponentModel.BindingList`1.FindCore(PropertyDescriptor
prop, Object key)
at
System.ComponentModel.BindingList`1.System.ComponentModel.IBindingList.Find(PropertyDescriptor
prop, Object key)
at
System.Windows.Forms.DataGridViewComboBoxCell.ItemFromComboBoxDataSource(PropertyDescriptor
property, Object key)
at
System.Windows.Forms.DataGridViewComboBoxCell.LookupDisplayValue(Int32
rowIndex, Object value, Object& displayValue)
at
System.Windows.Forms.DataGridViewComboBoxCell.GetFormattedValue(Object
value, Int32 rowIndex, DataGridViewCellStyle& cellStyle, TypeConverter
valueTypeConverter, TypeConverter formattedValueTypeConverter,
DataGridViewDataErrorContexts context)
.....
If I use normal BindingList class, grid displays without error.
How to fix ?
Linq as OrderBy method.
I'snt it more resonable to use its OrderBy() method instead of re-inventing
wheel by creating own comparer ?
This would reduce the amount of code a lot.
If yes, how to implement this with les code ?
Andrus.