I have a Datagridview which is binded to a ArcDataBinding.TableWrapper. So, I want it to be sorted when ColumnHeader is clicked. I tried to do the following on Click event:
ArcDataBinding.TableWrapper twapper = (ArcDataBinding.TableWrapper)((BindingSource)datagridview.DataSource).DataSource;
ITableSort tsort = new TableSortClass();
tsort.Table = (ITable)twapper.wrappedTable;
...
string column_name = datagridview.Columns[e.ColumnIndex].Name;
tsort.Fields = column_name;
tsort.set_Ascending(column_name, false);
tsort.set_CaseSensitive(column_name, true);
tsort.Sort(null);
...
ArcDataBinding.TableWrapper tableWrapper = new ArcDataBinding.TableWrapper((ITable)tsort);
tableWrapper.UseCVDomains = true;
BindingSource bindingSource1 = new BindingSource();
bindingSource1.DataSource = tableWrapper;
datagridview.DataSource = bindingSource1;
datagridview.Refresh();
But it doesn't seem to have any effect. Does anyone knows what is the problem?