Hello All,
The problem I'm having is when I programmatically sort my DataGridView I get the following exception:
System.InvalidOperationException: DataGridView control must be bound to an IBindingList object to be sorted.
This shouldn't be happening. The data source is a DataView which of course implements IBindingList which is clear in the following pic.
As you can see, the data source implements IBindingList and the SupportsSorting property is true. My problem may be the result of upgrading to Visual Studio 2013 because the code had been working for some time. Has anybody run across this before?
if (be.SortColumn.Length > 0 && DataGrid.Columns.Contains(be.SortColumn))
{
try
{
DataGrid.Sort(DataGrid.Columns[be.SortColumn], ListSortDirection.Ascending);
}
catch (Exception ex)
{
Debug.WriteLine("Column.Sort: " + be.SortColumn);
Debug.WriteLine("Error: " + ex.ToString());
}
}
-Paul
The problem I'm having is when I programmatically sort my DataGridView I get the following exception:
System.InvalidOperationException: DataGridView control must be bound to an IBindingList object to be sorted.
This shouldn't be happening. The data source is a DataView which of course implements IBindingList which is clear in the following pic.
As you can see, the data source implements IBindingList and the SupportsSorting property is true. My problem may be the result of upgrading to Visual Studio 2013 because the code had been working for some time. Has anybody run across this before?
if (be.SortColumn.Length > 0 && DataGrid.Columns.Contains(be.SortColumn))
{
try
{
DataGrid.Sort(DataGrid.Columns[be.SortColumn], ListSortDirection.Ascending);
}
catch (Exception ex)
{
Debug.WriteLine("Column.Sort: " + be.SortColumn);
Debug.WriteLine("Error: " + ex.ToString());
}
}
-Paul