【问题标题】:How to filter Datagrid using DateTime Picker?如何使用 DateTime Picker 过滤 Datagrid?
【发布时间】:2015-04-30 09:01:28
【问题描述】:

我在 Datagridview 中有两列,其中包含日期和时间戳以及状态(字符串),这些列来自定期更新的 sql db。

我想在 VB.net 中通过 datepicker 过滤 datagridview 中的数据。

谁能帮我怎么办?

【问题讨论】:

  • 到目前为止你尝试过什么?

标签: vb.net datagridview datagrid datepicker


【解决方案1】:

查看DataView.RowFilter 属性。这允许您使用 expressions 过滤 DataGridView 中的数据。

' Set the data source.
MyDataGridView.DataSource = myDataTable

' Set the filter.
DirectCast(MyDataGridView.DataSource, DataTable).DefaultView.RowFilter = String.Format("DateColumn = '{0:yyyy-MM-dd}'", MyDateTimePicker.Value)

【讨论】:

    猜你喜欢
    • 2015-07-07
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    • 2022-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-29
    相关资源
    最近更新 更多