DataGridView行过滤是否没有循环? [英] DataGridView Row Filtering Without a loop?

查看:85
本文介绍了DataGridView行过滤是否没有循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我使用datagridview填充csv文件中的数据.data是员工的打卡时间.datagridview没有数据源(由于需要进行一些计算而手动添加了行).是否有可能将datagridview数据检索到数据表或数据集中?因为我想根据打孔日期过滤行.我的目的是避免循环?有任何建议吗?

Hi iam using a datagridview it fill with data from a csv file.data is punching time of employees.the datagridview have no datasource(manually added the rows because some calculations are needed).is it possible to retrive the datagridview data to a datatable or dataset? because i want to filter the rows according to punching date..my aim is to avoid the looping ? any suggestions?

推荐答案

使用linq是个好主意.
但是,如果您要使用循环手动添加行,则只需将其添加到DataTable中而不是网格中,然后将网格的DataSource设置为DataTable.
Using linq is a good idea.
But if you are manually adding rows using a loop, then just add them to a DataTable instead of gird and set the DataSource of the grid to the DataTable.


您知道LINQ吗?
有一个LINQ to CSV,可以帮助减少这种事情所需的代码量.参见 http ://blogs.msdn.com/b/wriju/archive/2009/05/24/linq-to-csv-getting-data-the-way-you-want.aspx [
Do you know LINQ?
There is a LINQ to CSV that can help reduce the amount of code you need for this kind of thing. See http://blogs.msdn.com/b/wriju/archive/2009/05/24/linq-to-csv-getting-data-the-way-you-want.aspx[^] for example. You can bind the result of the LINQ query to a DataGrid after applying filter.


这篇关于DataGridView行过滤是否没有循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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