将datagridview日期从 - >过滤到 [英] Filtering datagridview date from->to

查看:59
本文介绍了将datagridview日期从 - >过滤到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找能够过滤范围内数据的能力

我制作了一个测试文件来显示问题: [ ^ ]

有什么想法吗?



我尝试了什么:



I'm looking for the ability to filter data in a range
I made a test file to show the problem : [^]
Any ideas?

What I have tried:

Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        Dim dv As New DataView(datatable, "DataW>=" & TextBox1.Text & "and DataW<=" & TextBox2.Text, "DataW", DataViewRowState.CurrentRows)
        DataGridView1.DataSource = dv
    End Sub

推荐答案

根据MSDN文档 - DataColumn.Expression属性(System.Data) [ ^ ]

使用日期值过滤时,您需要使用#或单引号括起值,具体取决于数据提供者。

此外,您的文本框有一个字符串值,用于表示日期。

如果DataW列中的数据类型是Date类型,那么我会推荐格式yyyymmdd。



亲切的问候
As per the MSDN documentation - DataColumn.Expression Property (System.Data)[^]
When filtering using Date values you need to surround the value with # or single quotes depending on the data provider.
Additionally, your Text boxes have a string value that you are using to represent a date.
If your datatype in the column DataW is a Date type then I would recommend the format yyyymmdd.

Kind Regards


这篇关于将datagridview日期从 - >过滤到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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