This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
64 lines (53 loc) · 2.04 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.Data.Filtering
Imports DevExpress.XtraGrid.Columns
Namespace WindowsApplication1
Partial Public Class Form1
Inherits Form
Private Function CreateTable(ByVal RowCount As Integer) As DataTable
Dim tbl As New DataTable()
tbl.Columns.Add("Name", GetType(String))
tbl.Columns.Add("ID", GetType(Integer))
tbl.Columns.Add("Number", GetType(Integer))
tbl.Columns.Add("Date", GetType(DateTime))
For i As Integer = 0 To RowCount - 1
tbl.Rows.Add(New Object() { String.Format("Name{0}", i), i, 3 - i, DateTime.Now.AddDays(i).AddMonths(i) })
Next i
Return tbl
End Function
Public Sub New()
InitializeComponent()
gridControl1.DataSource = CreateTable(20)
End Sub
Private ReadOnly Property FromDate() As DateTime
Get
Return dateEdit1.DateTime
End Get
End Property
Private ReadOnly Property ToDate() As DateTime
Get
Return dateEdit2.DateTime
End Get
End Property
Private Sub ApplyFilter()
If gridView1.Columns("Date") Is Nothing Then
Return
End If
Dim binaryFilter As CriteriaOperator = New GroupOperator(GroupOperatorType.And, New BinaryOperator("Date", FromDate, BinaryOperatorType.GreaterOrEqual), New BinaryOperator("Date", ToDate, BinaryOperatorType.Less))
Dim simplifiedFilter As CriteriaOperator = (New OperandProperty("Date") >= New OperandValue(FromDate)) And (New OperandProperty("Date") < New OperandValue(ToDate))
Dim filterDisplayText As String = String.Format("Date is between {0:d} and {1:d}", FromDate, ToDate)
Dim dateFilter As New ColumnFilterInfo(binaryFilter.ToString(), filterDisplayText)
gridView1.Columns("Date").FilterInfo = dateFilter
End Sub
Private Sub dateEdit_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles dateEdit2.EditValueChanged, dateEdit1.EditValueChanged
ApplyFilter()
End Sub
End Class
End Namespace