3 Imports System
.Collections
4 Imports System
.ComponentModel
7 Imports System
.Windows
.Forms
10 Public Class MyControl1
11 Inherits System
.Windows
.Forms
.UserControl
12 Private label1
As System
.Windows
.Forms
.Label
13 Private label2
As System
.Windows
.Forms
.Label
14 Private label3
As System
.Windows
.Forms
.Label
15 Private label4
As System
.Windows
.Forms
.Label
16 Private label5
As System
.Windows
.Forms
.Label
17 Private txtName
As System
.Windows
.Forms
.TextBox
18 Private txtAddress
As System
.Windows
.Forms
.TextBox
19 Private txtCity
As System
.Windows
.Forms
.TextBox
20 Private txtState
As System
.Windows
.Forms
.TextBox
21 Private txtZip
As System
.Windows
.Forms
.TextBox
22 Private label6
As System
.Windows
.Forms
.Label
23 Private WithEvents btnOK
As System
.Windows
.Forms
.Button
24 Private WithEvents btnCancel
As System
.Windows
.Forms
.Button
27 ' Required designer variable.
29 Private components
As System
.ComponentModel
.IContainer
= Nothing
34 ' This call is required by the Windows.Forms Form Designer.
39 Protected Overrides
Sub Dispose(ByVal disposing
As Boolean)
41 If Not (components Is
Nothing) Then
45 MyBase
.Dispose(disposing
)
49 #Region
"Component Designer generated code"
52 ' Required method for Designer support - do not modify
53 ' the contents of this method with the code editor.
55 Private Sub InitializeComponent()
56 Me.label1
= New System
.Windows
.Forms
.Label()
57 Me.label2
= New System
.Windows
.Forms
.Label()
58 Me.label3
= New System
.Windows
.Forms
.Label()
59 Me.label4
= New System
.Windows
.Forms
.Label()
60 Me.label5
= New System
.Windows
.Forms
.Label()
61 Me.txtName
= New System
.Windows
.Forms
.TextBox()
62 Me.txtAddress
= New System
.Windows
.Forms
.TextBox()
63 Me.txtCity
= New System
.Windows
.Forms
.TextBox()
64 Me.txtState
= New System
.Windows
.Forms
.TextBox()
65 Me.txtZip
= New System
.Windows
.Forms
.TextBox()
66 Me.btnOK
= New System
.Windows
.Forms
.Button()
67 Me.btnCancel
= New System
.Windows
.Forms
.Button()
68 Me.label6
= New System
.Windows
.Forms
.Label()
73 Me.label1
.Location
= New System
.Drawing
.Point(20, 46)
74 Me.label1
.Margin
= New System
.Windows
.Forms
.Padding(3, 3, 3, 1)
75 Me.label1
.Name
= "label1"
76 Me.label1
.Size
= New System
.Drawing
.Size(65, 16)
77 Me.label1
.TabIndex
= 8
78 Me.label1
.Text
= "Name"
79 Me.label1
.TextAlign
= System
.Drawing
.ContentAlignment
.MiddleLeft
83 Me.label2
.Location
= New System
.Drawing
.Point(20, 88)
84 Me.label2
.Name
= "label2"
85 Me.label2
.Size
= New System
.Drawing
.Size(94, 13)
86 Me.label2
.TabIndex
= 9
87 Me.label2
.Text
= "Street Address"
88 Me.label2
.TextAlign
= System
.Drawing
.ContentAlignment
.MiddleLeft
92 Me.label3
.Location
= New System
.Drawing
.Point(20, 127)
93 Me.label3
.Margin
= New System
.Windows
.Forms
.Padding(3, 3, 3, 2)
94 Me.label3
.Name
= "label3"
95 Me.label3
.Size
= New System
.Drawing
.Size(49, 13)
96 Me.label3
.TabIndex
= 10
97 Me.label3
.Text
= "City"
98 Me.label3
.TextAlign
= System
.Drawing
.ContentAlignment
.MiddleLeft
102 Me.label4
.Location
= New System
.Drawing
.Point(246, 127)
103 Me.label4
.Margin
= New System
.Windows
.Forms
.Padding(3, 0, 3, 3)
104 Me.label4
.Name
= "label4"
105 Me.label4
.Size
= New System
.Drawing
.Size(47, 13)
106 Me.label4
.TabIndex
= 11
107 Me.label4
.Text
= "State"
108 Me.label4
.TextAlign
= System
.Drawing
.ContentAlignment
.MiddleLeft
112 Me.label5
.Location
= New System
.Drawing
.Point(23, 167)
113 Me.label5
.Margin
= New System
.Windows
.Forms
.Padding(3, 3, 2, 3)
114 Me.label5
.Name
= "label5"
115 Me.label5
.Size
= New System
.Drawing
.Size(46, 13)
116 Me.label5
.TabIndex
= 12
117 Me.label5
.Text
= "Zip"
118 Me.label5
.TextAlign
= System
.Drawing
.ContentAlignment
.MiddleLeft
122 Me.txtName
.Location
= New System
.Drawing
.Point(135, 44)
123 Me.txtName
.Margin
= New System
.Windows
.Forms
.Padding(3, 2, 3, 3)
124 Me.txtName
.Name
= "txtName"
125 Me.txtName
.Size
= New System
.Drawing
.Size(199, 20)
126 Me.txtName
.TabIndex
= 0
130 Me.txtAddress
.Location
= New System
.Drawing
.Point(136, 84)
131 Me.txtAddress
.Margin
= New System
.Windows
.Forms
.Padding(3, 1, 3, 3)
132 Me.txtAddress
.Name
= "txtAddress"
133 Me.txtAddress
.Size
= New System
.Drawing
.Size(198, 20)
134 Me.txtAddress
.TabIndex
= 1
138 Me.txtCity
.Location
= New System
.Drawing
.Point(136, 123)
139 Me.txtCity
.Name
= "txtCity"
140 Me.txtCity
.TabIndex
= 2
144 Me.txtState
.Location
= New System
.Drawing
.Point(300, 123)
145 Me.txtState
.Name
= "txtState"
146 Me.txtState
.Size
= New System
.Drawing
.Size(33, 20)
147 Me.txtState
.TabIndex
= 3
151 Me.txtZip
.Location
= New System
.Drawing
.Point(135, 163)
152 Me.txtZip
.Margin
= New System
.Windows
.Forms
.Padding(1, 3, 3, 3)
153 Me.txtZip
.Name
= "txtZip"
154 Me.txtZip
.TabIndex
= 4
158 Me.btnOK
.Location
= New System
.Drawing
.Point(23, 207)
159 Me.btnOK
.Margin
= New System
.Windows
.Forms
.Padding(3, 3, 3, 1)
160 Me.btnOK
.Name
= "btnOK"
161 Me.btnOK
.TabIndex
= 5
166 Me.btnCancel
.Location
= New System
.Drawing
.Point(157, 207)
167 Me.btnCancel
.Name
= "btnCancel"
168 Me.btnCancel
.TabIndex
= 6
169 Me.btnCancel
.Text
= "Cancel"
173 Me.label6
.Location
= New System
.Drawing
.Point(66, 12)
174 Me.label6
.Name
= "label6"
175 Me.label6
.Size
= New System
.Drawing
.Size(226, 23)
176 Me.label6
.TabIndex
= 13
177 Me.label6
.Text
= "Simple Windows Forms Control"
178 Me.label6
.TextAlign
= System
.Drawing
.ContentAlignment
.MiddleCenter
182 Me.Controls
.Add(label6
)
183 Me.Controls
.Add(btnCancel
)
184 Me.Controls
.Add(btnOK
)
185 Me.Controls
.Add(txtZip
)
186 Me.Controls
.Add(txtState
)
187 Me.Controls
.Add(txtCity
)
188 Me.Controls
.Add(txtAddress
)
189 Me.Controls
.Add(txtName
)
190 Me.Controls
.Add(label5
)
191 Me.Controls
.Add(label4
)
192 Me.Controls
.Add(label3
)
193 Me.Controls
.Add(label2
)
194 Me.Controls
.Add(label1
)
195 Me.Name
= "MyControl1"
196 Me.Size
= New System
.Drawing
.Size(359, 244)
197 Me.ResumeLayout(False)
204 Public Delegate
Sub MyControlEventHandler(ByVal sender
As Object, ByVal args
As MyControlEventArgs
)
205 Public Event OnButtonClick
As MyControlEventHandler
207 Private Sub OKButton_Click(ByVal sender
As Object, ByVal e
As System
.EventArgs
) Handles btnOK
.Click
209 Dim retvals
As New MyControlEventArgs(True, txtName
.Text
, txtAddress
.Text
, txtCity
.Text
, txtState
.Text
, txtZip
.Text
)
210 RaiseEvent OnButtonClick(Me, retvals
)
215 Private Sub CancelButton_Click(ByVal sender
As Object, ByVal e
As System
.EventArgs
) Handles btnCancel
.Click
216 Dim retvals
As New MyControlEventArgs(False, txtName
.Text
, txtAddress
.Text
, txtCity
.Text
, txtState
.Text
, txtZip
.Text
)
217 RaiseEvent OnButtonClick(Me, retvals
)
222 Public Class MyControlEventArgs
224 Private _Name
As String
225 Private _StreetAddress
As String
226 Private _City
As String
227 Private _State
As String
228 Private _Zip
As String
229 Private _IsOK
As Boolean
232 Public Sub New(ByVal result
As Boolean, ByVal name
As String, ByVal address
As String, ByVal city
As String, ByVal state
As String, ByVal zip
As String)
235 _StreetAddress
= address
243 Public Property MyName() As String
252 Public Property MyStreetAddress() As String
254 Return _StreetAddress
257 _StreetAddress
= value
261 Public Property MyCity() As String
270 Public Property MyState() As String
279 Public Property MyZip() As String
288 Public Property IsOK() As Boolean