如何过滤datafridview表并将其显示到另一个表中

编程入门 行业动态 更新时间:2024-10-28 13:17:27
本文介绍了如何过滤datafridview表并将其显示到另一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨大家好: 我正在使用Windows Forms C#来开发我的应用程序。在我的表单中,我有2个datagridview(dataGridView1和dataGridView2)。 dataGridView1是一个数据源表。在我的表中,我有PurchaseDateTime。我有用户条目的DateTimePicker。 我想通过更改dateTimePicker中的值来过滤dataGridView1,并将过滤后的数据显示到dataGridView2中。 我在网上冲了很多,但没有找到任何有用的东西。 如果你能帮我,我很感激。

Hi Guys: I am using Windows Forms C# to develop my application. In my form I have 2 datagridview ( dataGridView1 and dataGridView2) . dataGridView1 is boud to a datasource table. In my table I have PurchaseDateTime. I have DateTimePicker for the user entry. I want to filter my dataGridView1 by the change of value in my dateTimePicker and show the filtered data into dataGridView2. I surfed the webs alot, but didn''t find anything useful. I appreciate if you help me.

推荐答案

在datepicker'的valuechanged事件中你可以做类似的事情 On the datepicker''s valuechanged event you can do something like this DataSet ds = ((BindingSource)(dataGridView1.DataSource)).DataSource as DataSet; DataRow[] res = ds.Tables[0].Select("date = ''" + dateTimePicker1.Value.ToShortDateString() + "''"); dataGridView2.DataSource = res;

更多推荐

如何过滤datafridview表并将其显示到另一个表中

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

发布评论

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

>www.elefans.com

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