D
Dennis McCarthy
I have a DataGrid that is bound to a DataTable in a typed
DataSet. The following code is used to get the current
row in the DataGrid, even after the user has clicked on a
column header to sort:
BindingManagerBase bm = this.dataGrid1.BindingContext
[this.dataGrid1.DataSource, this.dataGrid1.DataMember];
DataRow dr = ((DataRowView)bm.Current).Row;
I would like to have the DataGrid initially be sorted,
just as if the user had clicked on the first column
header. I tried doing this by binding the DataGrid to
sorted DataView.
DataView view = new DataView (MyDataSet.MyDataTable);
view.Sort = "NAME";
dataGrid1.DataSource = view;
This works for sorting, but breaks the logic above for
getting the current row. No matter what row the user
selects, the binding manager always has the same current
row.
How can I pre-sort my DataGrid without losing the ability
to track the current row?
Thanks,
Dennis
DataSet. The following code is used to get the current
row in the DataGrid, even after the user has clicked on a
column header to sort:
BindingManagerBase bm = this.dataGrid1.BindingContext
[this.dataGrid1.DataSource, this.dataGrid1.DataMember];
DataRow dr = ((DataRowView)bm.Current).Row;
I would like to have the DataGrid initially be sorted,
just as if the user had clicked on the first column
header. I tried doing this by binding the DataGrid to
sorted DataView.
DataView view = new DataView (MyDataSet.MyDataTable);
view.Sort = "NAME";
dataGrid1.DataSource = view;
This works for sorting, but breaks the logic above for
getting the current row. No matter what row the user
selects, the binding manager always has the same current
row.
How can I pre-sort my DataGrid without losing the ability
to track the current row?
Thanks,
Dennis