This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.vb
57 lines (56 loc) · 1.89 KB
/
MainWindow.xaml.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
Imports Microsoft.VisualBasic
Imports System.Windows
Imports System.Windows.Controls
Imports DevExpress.Xpf.PivotGrid
Namespace DXPivotGrid_GroupFilter
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.pivotGridControl1.DataSource = GetTimeTableView()
fieldMonth.CollapseAll()
End Sub
Private Sub RadioButtonList_SelectionChanged(ByVal sender As Object, _
ByVal e As SelectionChangedEventArgs)
If pivotGridControl1 Is Nothing Then
Return
End If
Me.pivotGridControl1.BeginUpdate()
Dim group As PivotGridGroup = Me.pivotGridControl1.Groups(0)
group.FilterValues.Reset()
group.FilterValues.BeginUpdate()
Select Case radioGroup1.SelectedIndex
Case 0
group.FilterValues.FilterType = FieldFilterType.Excluded
Case 1
group.FilterValues.FilterType = FieldFilterType.Included
group.FilterValues.Values.Add(2009).ChildValues.Add(12)
group.FilterValues.Values.Add(2010).ChildValues.Add(1)
Case 2
group.FilterValues.FilterType = FieldFilterType.Excluded
group.FilterValues.Values.Add(2009)
Case 3
group.FilterValues.FilterType = FieldFilterType.Included
SelectFirstDays(group)
End Select
group.FilterValues.EndUpdate()
Me.pivotGridControl1.EndUpdate()
If radioGroup1.SelectedIndex = 3 Then
fieldMonth.ExpandAll()
Else
fieldMonth.CollapseAll()
End If
End Sub
Private Sub SelectFirstDays(ByVal group As PivotGridGroup)
For Each year As Object In group.GetUniqueValues(Nothing)
Dim value As DevExpress.XtraPivotGrid.PivotGroupFilterValue = _
group.FilterValues.Values.Add(year)
For Each month As Object In group.GetUniqueValues(New Object() { year })
value.ChildValues.Add(month).ChildValues.Add(1)
Next month
Next year
End Sub
End Class
End Namespace