This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
MyCompositeControl.vb
68 lines (59 loc) · 2.17 KB
/
MyCompositeControl.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
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports DevExpress.XtraReports.UI
Imports System.ComponentModel
Imports DevExpress.XtraReports
Imports DevExpress.XtraReports.Design
Imports DevExpress.XtraReports.Design.Behaviours
Imports System.ComponentModel.Design
Namespace CustomControls
<ToolboxItem(True), XRDesigner("CustomControls.MyPanelDesigner"), Designer("CustomControls.MyPanelDesigner")>
Public Class MyCompositeControl
Inherits XRPanel
Public Sub New()
MyBase.New()
Me.SizeF = New System.Drawing.SizeF(200, 50)
End Sub
End Class
<DesignerBehaviour(GetType(MyPanelDesignerBehaviour))>
Public Class MyPanelDesigner
Inherits XRPanelDesigner
Public Sub New()
MyBase.New()
End Sub
Public Sub InitControls()
Dim panel As MyCompositeControl = TryCast(Me.XRControl, MyCompositeControl)
Dim label1 As New XRLabel()
label1.ExpressionBindings.Add(New ExpressionBinding("Text","[ProductID]"))
label1.SizeF = New System.Drawing.SizeF(200, 25)
panel.Controls.Add(label1)
Dim label2 As New XRLabel()
panel.Controls.Add(label2)
label2.SizeF = New System.Drawing.SizeF(200, 25)
label2.LocationF = New System.Drawing.PointF(0, 25)
label2.ExpressionBindings.Add(New ExpressionBinding("Text", "[ProductName]"))
End Sub
Public Sub AddChildControlsToContainer()
Dim panel As MyCompositeControl = TryCast(Me.XRControl, MyCompositeControl)
For Each childControl As XRControl In panel.Controls
Dim loc As System.Drawing.PointF = childControl.LocationF
Dim designerHost As IDesignerHost = DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
DesignToolHelper.AddToContainer(designerHost, childControl)
childControl.LocationF = loc
Next childControl
End Sub
End Class
Public Class MyPanelDesignerBehaviour
Inherits DesignerBehaviour
Public Sub New(ByVal servProvider As IServiceProvider)
MyBase.New(servProvider)
End Sub
Public Overrides Sub SetDefaultComponentBounds()
MyBase.SetDefaultComponentBounds()
TryCast(Designer, MyPanelDesigner).InitControls()
TryCast(Designer, MyPanelDesigner).AddChildControlsToContainer()
End Sub
End Class
End Namespace