在日期之间过滤datagridview

问题描述:

我需要过滤日期和时间之间的datagridview

我所拥有的是开始和结束日期以及开始和结束时间.在我的表单上,我有一个日期文本框和时间,它们是当前时间和日期.因此,当表单打开时,我想过滤datagridview,其中enddate小于或等于日期文本框,然后starttime和endtime在时间文本框之间.到目前为止我有这个

I need to filter a datagridview between dates and times

What I have is a start and End Date and start and end time. On my form I have a date textbox and time that are the current time and date. So when the form opens I want to filter the datagridview where the enddate is less than or equal to the date textbox and then starttime and endtime are between the time textbox. I have this so far

Dim value10 As String = Me.DateTextBox.Text
        Dim value11 As String = Me.TimeTextBox.Text



Me.TblShiftBindingSource.Filter ="StartDate< =''"&值10& "和EndDate> ="&值10& "和StartTime< ="& value11& "和EndTime>"& value11& ""



Me.TblShiftBindingSource.Filter = "StartDate <= ''" & value10 & "'' and EndDate >= ''" & value10 & "'' and StartTime <= ''" & value11 & "'' and EndTime > ''" & value11 & "''"

这里是一个示例:
使用BindingSource和DataView过滤在DataGridView中显示的数据 [
Here is an example:
Filter data dispalyed in a DataGridView using BindingSource and DataView[^]

Hope it helps.
Regards
Espen Harlinn