我需要一个快速的解决方案,就像在Excel中一样,使用Winforms DataGridView控件进行过滤/排序。
Hi I need a quick solution to do filtering/sorting using the Winforms DataGridView control just as in Excel.
我已经查看了该区域的现有帖子,但没有似乎满足了我的需求。
I have reviewed the existing posts on this area but none seems to meet my needs.
我正在手动填充DataGridView-没有数据绑定
I am populating my DataGridView manually - no data binding
推荐答案DataGridView列已支持排序。
The DataGridView columns already support sorting.
我将用您的数据填充DataTable,然后将DataGridView绑定到myDataTable.DefaultView。
I would populate a DataTable with your data and then bind the DataGridView to myDataTable.DefaultView.
您可以通过设置myDataTable.DefaultView.RowFilter来过滤显示的行。
You can filter the rows displayed by setting myDataTable.DefaultView.RowFilter.
您可以将文本框和/或组合框放在上方DataGridView并在输入/选择更改时更新myDataTable.DefaultView.RowFilter。
You could place Textboxes and/or Comboboxes above the DataGridView and update myDataTable.DefaultView.RowFilter as the input/selections change.
更多推荐
C#Winforms DataGridView像MS Excel一样进行排序/过滤
发布评论