C#Winforms DataGridView像MS Excel一样进行排序/过滤

编程入门 行业动态 更新时间:2024-10-21 09:58:18
本文介绍了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一样进行排序/过滤

本文发布于:2023-11-08 07:12:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568697.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DataGridView   Winforms   Excel   MS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!