【发布时间】:2009-08-25 01:13:09
【问题描述】:
我有一个绑定到 DataTable 的 DataGridView,有没有办法重新排序 DataGridView 中的行并将更改反映在绑定的 DataTable 中?
【问题讨论】:
标签: winforms datagridview
我有一个绑定到 DataTable 的 DataGridView,有没有办法重新排序 DataGridView 中的行并将更改反映在绑定的 DataTable 中?
【问题讨论】:
标签: winforms datagridview
在DataTable 和DataGridView 之间使用DataView 或BindingSource,它们都有Sort 属性:
DataView view = new DataView(table);
view.Sort = "Name ASC, Age Desc";
dataGridView.DataSource = view;
您还可以使用DataView.RowFilter 属性(或BindingSource.Filter)过滤结果。
DataGridView 将自动反映更改
【讨论】: