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
64 lines (56 loc) · 1.87 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
58
59
60
61
62
63
64
Imports System
Imports System.Data
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid
Namespace DXPivotGrid_BeginEndUpdate
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
pivotGridControl1.DataSource = GetDataTable()
End Sub
Private Sub btnRun_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim startTime As DateTime = DateTime.Now
' If an appropriate option is enabled,
' locks the pivot grid to prevent further updates.
If rbLocked.IsChecked = True Then
pivotGridControl1.BeginUpdate()
End If
Try
' Initiates transposition.
Transpose()
Finally
' If the pivot grid has been locked, unlocks it, allowing further updates.
If rbLocked.IsChecked = True Then
pivotGridControl1.EndUpdate()
End If
End Try
' Displays the amount of time taken by the transposition.
Dim duration As TimeSpan = DateTime.Now.Subtract(startTime)
MessageBox.Show("Transposition took " & duration.TotalSeconds.ToString("F2") & " seconds")
End Sub
' Transposes the pivot grid by moving Row Fields to the Column Area, and vice versa.
Private Sub Transpose()
For Each field As PivotGridField In pivotGridControl1.Fields
If field.Area = FieldArea.RowArea Then
field.Area = FieldArea.ColumnArea
ElseIf field.Area = FieldArea.ColumnArea Then
field.Area = FieldArea.RowArea
End If
Next field
End Sub
' Generates pivot grid data.
Public Shared Function GetDataTable() As DataTable
Dim table As New DataTable()
table.Columns.Add("A", GetType(String))
table.Columns.Add("B", GetType(String))
table.Columns.Add("Data", GetType(Integer))
For i As Integer = 0 To 999
For j As Integer = 0 To 499
table.Rows.Add("A"c & i.ToString(), "B"c & j.ToString(), (CInt(i) \ 100))
Next j
Next i
Return table
End Function
End Class
End Namespace