/
Form1.vb
91 lines (84 loc) · 2.71 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
Imports Microsoft.VisualBasic
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
Imports DevExpress.Xpo
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.Data.Filtering
Imports DevExpress.XtraGrid.Columns
Imports System.Reflection
Imports System.Threading
Namespace WindowsFormsSample
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
For i As Integer = 0 To 4
Dim parent As New Parent()
parent.Name = i.ToString()
parentBindingSource.Add(parent)
Next i
End Sub
Private Sub gridView1_MasterRowGetRelationCount(ByVal sender As Object, ByVal e As MasterRowGetRelationCountEventArgs) Handles gridView1.MasterRowGetRelationCount
e.RelationCount = 1
End Sub
Private Sub gridView1_MasterRowEmpty(ByVal sender As Object, ByVal e As MasterRowEmptyEventArgs) Handles gridView1.MasterRowEmpty
e.IsEmpty = False
End Sub
Private Sub gridView1_MasterRowGetRelationName(ByVal sender As Object, ByVal e As MasterRowGetRelationNameEventArgs) Handles gridView1.MasterRowGetRelationName
e.RelationName = "Children"
End Sub
Private Sub gridView1_MasterRowGetChildList(ByVal sender As Object, ByVal e As MasterRowGetChildListEventArgs) Handles gridView1.MasterRowGetChildList
Dim details As New BindingList(Of Child)()
e.ChildList = details
Dim worker As New BackgroundWorker()
AddHandler worker.DoWork, AddressOf worker_DoWork
worker.RunWorkerAsync(details)
End Sub
Private Sub worker_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
Dim details As BindingList(Of Child) = CType(e.Argument, BindingList(Of Child))
For i As Integer = 0 To 99
BeginInvoke(New MethodInvoker(Function() AnonymousMethod1(i, details)))
Thread.Sleep(1000)
Next i
End Sub
Private Function AnonymousMethod1(ByVal i As Integer, ByVal details As BindingList(Of Child)) As Boolean
Dim child As New Child()
child.Name = i.ToString()
details.Add(child)
Return True
End Function
End Class
Public Class Parent
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
End Class
Public Class Child
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
End Class
End Namespace