0
votes

I'm trying to sort a column in a standard windows forms datagridview.

Visual Studio 2015 Target .net Framework: 4.5.2

I've set AllowUsersToOrderColumns to True. All columns have SortMode set to Automatic. My data source is a BindingList of objects. All columns have the DataPropertyName set. The grid loads and displays fine. I don't see the up/down arrow and clicking the column header does nothing. Do I have to implement some code? I thought this was default behavior. What am I missing please?

Thank you.

The BindingList<T> class doesn't support sorting. You'll have to derive from it and implement sorting. See the docs. - Steeeve
...or use a DataTable, which already implements all sorting / filtering / notifying / selecting stuff out of the box. Using a simple BindingList, you also need to implement INotifyPropertyChanged in your class objects (and nested custom types, eventually). Or use an ORM / mini-ORM. -- If it's not a requirement of sort, update your .Net Framework version, 4.5.2 is quite old. - Jimi