C#Winforms DataGridView像MS Excel一样进行排序/过滤 [英] C# Winforms DataGridView with sorting/filtering like Ms Excel

查看:164
本文介绍了C#Winforms DataGridView像MS Excel一样进行排序/过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个快速的解决方案,就像在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一样进行排序/过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆