-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
147 lines (136 loc) · 3.67 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Imports Microsoft.VisualBasic
Imports DevExpress.XtraGrid.Views.Grid
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Namespace TestMasterDetailSelection
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
gridControl1.DataSource = GetData(10, 10)
Dim TempMasterDetailSelectionHelper As MasterDetailSelectionHelper = New MasterDetailSelectionHelper(gridView1)
End Sub
Private Function GetData(ByVal custCount As Integer, ByVal orderCount As Integer) As BindingList(Of Customer)
Dim custList As New BindingList(Of Customer)()
Dim r As New Random()
For i As Integer = 0 To custCount - 1
Dim cust As Customer = custList.AddNew()
cust.ID = i
cust.Name = "Name" & i
For j As Integer = 0 To orderCount - 1
cust.Orders.Add(New Order() With {.ID = j})
Dim productCount As Integer = r.Next(10)
For k As Integer = 0 To productCount - 1
cust.Orders(j).Products.Add(New Product() With {.ID = k, .Name = "Product" & k, .Price = r.Next(100)})
Next k
Next j
Next i
Return custList
End Function
Private Sub gridControl1_ViewRegistered(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.ViewOperationEventArgs) Handles gridControl1.ViewRegistered
Dim TempMasterDetailSelectionHelper As MasterDetailSelectionHelper = New MasterDetailSelectionHelper(TryCast(e.View, GridView))
End Sub
End Class
Public Class Customer
Public Sub New()
_Orders = New BindingList(Of Order)()
End Sub
Private _ID As Integer = 0
Private _Name As String = ""
Private _Orders As BindingList(Of Order)
Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal value As Integer)
_ID = value
End Set
End Property
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property Orders() As BindingList(Of Order)
Get
Return _Orders
End Get
Set(ByVal value As BindingList(Of Order))
_Orders = value
End Set
End Property
End Class
Public Class Order
Public Sub New()
_Products = New BindingList(Of Product)()
End Sub
Private _ID As Integer = 0
Private _Products As BindingList(Of Product)
Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal value As Integer)
_ID = value
End Set
End Property
Public ReadOnly Property Sum() As Integer
Get
'INSTANT VB NOTE: The local variable sum was renamed since Visual Basic will not allow local variables with the same name as their enclosing function or property:
Dim sum_Renamed As Integer = 0
For Each product As Product In _Products
sum_Renamed += product.Price
Next product
Return sum_Renamed
End Get
End Property
Public Property Products() As BindingList(Of Product)
Get
Return _Products
End Get
Set(ByVal value As BindingList(Of Product))
_Products = value
End Set
End Property
End Class
Public Class Product
Public Sub New()
End Sub
Private _ID As Integer = 0
Private _Name As String = ""
Private _Price As Integer = 0
Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal value As Integer)
_ID = value
End Set
End Property
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property Price() As Integer
Get
Return _Price
End Get
Set(ByVal value As Integer)
_Price = value
End Set
End Property
End Class
End Namespace