/
Form1.vb
75 lines (67 loc) · 2.83 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
65
66
67
68
69
70
71
72
73
74
75
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraPivotGrid
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Namespace DrillDownDataSourceExample
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Private serverMode As Boolean = False
Public Sub New()
InitializeComponent()
AddHandler pivotGridControl1.CellDoubleClick, AddressOf PivotGridControl1_CellDoubleClick
' This line of code is generated by Data Source Configuration Wizard
linqServerModeSource1.QueryableSource = (New DrillDownDataSourceExample.DataClasses1DataContext()).Invoices
End Sub
Private Sub PivotGridControl1_CellDoubleClick(ByVal sender As Object, ByVal e As DevExpress.XtraPivotGrid.PivotCellEventArgs)
Dim drillDownDataSource As PivotDrillDownDataSource
If serverMode Then
drillDownDataSource = e.CreateDrillDownDataSource(25, New List(Of String) From {"ShipName"})
Else
drillDownDataSource = e.CreateDrillDownDataSource(25)
End If
Dim dataform As XtraForm = CreateDrillDownForm(drillDownDataSource)
dataform.ShowDialog()
dataform.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
' TODO: This line of code loads data into the 'nWDataSet.Invoices' table. You can move, or remove it, as needed.
Me.invoicesTableAdapter.Fill(Me.nWDataSet.Invoices)
SetPivotGridDataSource()
End Sub
Private Function CreateDrillDownForm(ByVal dataSource As PivotDrillDownDataSource) As XtraForm
Dim form As New XtraForm()
Dim grid As New GridControl()
grid.Parent = form
grid.Dock = DockStyle.Fill
grid.DataSource = dataSource
form.Bounds = New Rectangle(100, 100, 800, 400)
grid.DataSource = form.Bounds
Dim gridView1 As New GridView()
grid.MainView = gridView1
gridView1.Columns("OrderDate").DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime
form.Text = String.Format("Underlying Data - {0} Records", dataSource.RowCount)
Return form
End Function
Private Sub toggleSwitch1_Toggled(ByVal sender As Object, ByVal e As EventArgs) Handles toggleSwitch1.Toggled
serverMode = DirectCast(sender, ToggleSwitch).IsOn
SetPivotGridDataSource()
End Sub
Private Sub SetPivotGridDataSource()
If serverMode Then
pivotGridControl1.DataSource = linqServerModeSource1
Else
pivotGridControl1.DataSource = invoicesBindingSource
End If
End Sub
Private Sub btnGrandTotal_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGrandTotal.Click
Dim drillDownDataSource As PivotDrillDownDataSource = pivotGridControl1.CreateDrillDownDataSource()
Dim dataform As Form = CreateDrillDownForm(drillDownDataSource)
dataform.ShowDialog()
dataform.Dispose()
End Sub
End Class
End Namespace