added samples
[windows-sources.git] / sdk / samples / WPFSamples / WpfHostingWindowsFormsControl / visualbasic / mycontrols / mycontrol1.vb
blob24d3db139b9dce2c8bc84e00d1c4bc1ac9f94e85
1 ' <snippet1>
2 Imports System
3 Imports System.Collections
4 Imports System.ComponentModel
5 Imports System.Drawing
6 Imports System.Data
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
26 ' <summary>
27 ' Required designer variable.
28 ' </summary>
29 Private components As System.ComponentModel.IContainer = Nothing
32 Public Sub New()
34 ' This call is required by the Windows.Forms Form Designer.
35 InitializeComponent()
37 End Sub
39 Protected Overrides Sub Dispose(ByVal disposing As Boolean)
40 If disposing Then
41 If Not (components Is Nothing) Then
42 components.Dispose()
43 End If
44 End If
45 MyBase.Dispose(disposing)
47 End Sub 'Dispose
49 #Region "Component Designer generated code"
51 ' <summary>
52 ' Required method for Designer support - do not modify
53 ' the contents of this method with the code editor.
54 ' </summary>
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()
69 Me.SuspendLayout()
71 ' label1
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
81 ' label2
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
90 ' label3
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
100 ' label4
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
110 ' label5
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
120 ' txtName
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
128 ' txtAddress
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
136 ' txtCity
138 Me.txtCity.Location = New System.Drawing.Point(136, 123)
139 Me.txtCity.Name = "txtCity"
140 Me.txtCity.TabIndex = 2
142 ' txtState
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
149 ' txtZip
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
156 ' btnOK
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
162 Me.btnOK.Text = "OK"
164 ' btnCancel
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"
171 ' label6
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
180 ' MyControl1
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)
198 Me.PerformLayout()
200 End Sub
201 #End Region
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)
212 End Sub
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)
219 End Sub
220 End Class
222 Public Class MyControlEventArgs
223 Inherits EventArgs
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)
233 _IsOK = result
234 _Name = name
235 _StreetAddress = address
236 _City = city
237 _State = state
238 _Zip = zip
240 End Sub
243 Public Property MyName() As String
245 Return _Name
246 End Get
248 _Name = value
249 End Set
250 End Property
252 Public Property MyStreetAddress() As String
254 Return _StreetAddress
255 End Get
257 _StreetAddress = value
258 End Set
259 End Property
261 Public Property MyCity() As String
263 Return _City
264 End Get
266 _City = value
267 End Set
268 End Property
270 Public Property MyState() As String
272 Return _State
273 End Get
275 _State = value
276 End Set
277 End Property
279 Public Property MyZip() As String
281 Return _Zip
282 End Get
284 _Zip = value
285 End Set
286 End Property
288 Public Property IsOK() As Boolean
290 Return _IsOK
291 End Get
293 _IsOK = value
294 End Set
295 End Property
296 End Class
297 ' </snippet1>