This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
304 lines (290 loc) · 12 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Controls
Namespace SearchHelper
''' <summary>
''' Summary description for Form1.
''' </summary>
Public Class Form1
Inherits System.Windows.Forms.Form
Private textEdit1 As DevExpress.XtraEditors.TextEdit
Private dateEdit1 As DevExpress.XtraEditors.DateEdit
Private spinEdit1 As DevExpress.XtraEditors.SpinEdit
Private dataNavigator1 As DevExpress.XtraEditors.DataNavigator
Private label1 As System.Windows.Forms.Label
Private label2 As System.Windows.Forms.Label
Private label3 As System.Windows.Forms.Label
Private listBoxControl1 As DevExpress.XtraEditors.ListBoxControl
Private label4 As System.Windows.Forms.Label
Private groupControl1 As DevExpress.XtraEditors.GroupControl
Private groupControl2 As DevExpress.XtraEditors.GroupControl
Private label5 As System.Windows.Forms.Label
Private label6 As System.Windows.Forms.Label
Private WithEvents lookUpEdit1 As DevExpress.XtraEditors.LookUpEdit
''' <summary>
''' Required designer variable.
''' </summary>
Private components As System.ComponentModel.Container = Nothing
Public Sub New()
'
' Required for Windows Form Designer support
'
InitializeComponent()
'
' TODO: Add any constructor code after InitializeComponent call
'
End Sub
''' <summary>
''' Clean up any resources being used.
''' </summary>
Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#Region "Windows Form Designer generated code"
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
Me.textEdit1 = New DevExpress.XtraEditors.TextEdit()
Me.dateEdit1 = New DevExpress.XtraEditors.DateEdit()
Me.spinEdit1 = New DevExpress.XtraEditors.SpinEdit()
Me.dataNavigator1 = New DevExpress.XtraEditors.DataNavigator()
Me.label1 = New System.Windows.Forms.Label()
Me.label2 = New System.Windows.Forms.Label()
Me.label3 = New System.Windows.Forms.Label()
Me.listBoxControl1 = New DevExpress.XtraEditors.ListBoxControl()
Me.label4 = New System.Windows.Forms.Label()
Me.groupControl1 = New DevExpress.XtraEditors.GroupControl()
Me.groupControl2 = New DevExpress.XtraEditors.GroupControl()
Me.lookUpEdit1 = New DevExpress.XtraEditors.LookUpEdit()
Me.label6 = New System.Windows.Forms.Label()
Me.label5 = New System.Windows.Forms.Label()
CType(Me.textEdit1.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.dateEdit1.Properties.VistaTimeProperties, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.dateEdit1.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.spinEdit1.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.listBoxControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.groupControl1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.groupControl1.SuspendLayout()
CType(Me.groupControl2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.groupControl2.SuspendLayout()
CType(Me.lookUpEdit1.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
' textEdit1
'
Me.textEdit1.EditValue = "textEdit1"
Me.textEdit1.Location = New System.Drawing.Point(144, 37)
Me.textEdit1.Name = "textEdit1"
Me.textEdit1.Size = New System.Drawing.Size(221, 22)
Me.textEdit1.TabIndex = 1
'
' dateEdit1
'
Me.dateEdit1.EditValue = New System.DateTime(2005, 12, 9, 0, 0, 0, 0)
Me.dateEdit1.Location = New System.Drawing.Point(144, 83)
Me.dateEdit1.Name = "dateEdit1"
Me.dateEdit1.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() { New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
Me.dateEdit1.Properties.VistaTimeProperties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() { New DevExpress.XtraEditors.Controls.EditorButton()})
Me.dateEdit1.Size = New System.Drawing.Size(221, 22)
Me.dateEdit1.TabIndex = 3
'
' spinEdit1
'
Me.spinEdit1.EditValue = New Decimal(New Integer() { 0, 0, 0, 0})
Me.spinEdit1.Location = New System.Drawing.Point(144, 129)
Me.spinEdit1.Name = "spinEdit1"
Me.spinEdit1.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() { New DevExpress.XtraEditors.Controls.EditorButton()})
Me.spinEdit1.Properties.DisplayFormat.FormatString = "c"
Me.spinEdit1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
Me.spinEdit1.Properties.Mask.EditMask = "c"
Me.spinEdit1.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None
Me.spinEdit1.Size = New System.Drawing.Size(221, 22)
Me.spinEdit1.TabIndex = 5
'
' dataNavigator1
'
Me.dataNavigator1.Location = New System.Drawing.Point(19, 175)
Me.dataNavigator1.Name = "dataNavigator1"
Me.dataNavigator1.Size = New System.Drawing.Size(349, 28)
Me.dataNavigator1.TabIndex = 6
Me.dataNavigator1.Text = "dataNavigator1"
Me.dataNavigator1.TextLocation = DevExpress.XtraEditors.NavigatorButtonsTextLocation.Center
'
' label1
'
Me.label1.Location = New System.Drawing.Point(19, 37)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(120, 18)
Me.label1.TabIndex = 0
Me.label1.Text = "Name:"
'
' label2
'
Me.label2.Location = New System.Drawing.Point(19, 83)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(120, 19)
Me.label2.TabIndex = 2
Me.label2.Text = "Purchase Date:"
'
' label3
'
Me.label3.Location = New System.Drawing.Point(19, 129)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(120, 19)
Me.label3.TabIndex = 4
Me.label3.Text = "Payment Amount:"
'
' listBoxControl1
'
Me.listBoxControl1.Location = New System.Drawing.Point(154, 120)
Me.listBoxControl1.Name = "listBoxControl1"
Me.listBoxControl1.Size = New System.Drawing.Size(211, 138)
Me.listBoxControl1.TabIndex = 5
'
' label4
'
Me.label4.Location = New System.Drawing.Point(19, 120)
Me.label4.Name = "label4"
Me.label4.Size = New System.Drawing.Size(120, 18)
Me.label4.TabIndex = 4
Me.label4.Text = "All Contacts:"
'
' groupControl1
'
Me.groupControl1.Controls.Add(Me.label3)
Me.groupControl1.Controls.Add(Me.label1)
Me.groupControl1.Controls.Add(Me.dataNavigator1)
Me.groupControl1.Controls.Add(Me.label2)
Me.groupControl1.Controls.Add(Me.dateEdit1)
Me.groupControl1.Controls.Add(Me.spinEdit1)
Me.groupControl1.Controls.Add(Me.textEdit1)
Me.groupControl1.Dock = System.Windows.Forms.DockStyle.Top
Me.groupControl1.Location = New System.Drawing.Point(0, 0)
Me.groupControl1.Name = "groupControl1"
Me.groupControl1.Size = New System.Drawing.Size(386, 222)
Me.groupControl1.TabIndex = 0
Me.groupControl1.Text = "Contact information"
'
' groupControl2
'
Me.groupControl2.Controls.Add(Me.lookUpEdit1)
Me.groupControl2.Controls.Add(Me.label6)
Me.groupControl2.Controls.Add(Me.label5)
Me.groupControl2.Controls.Add(Me.listBoxControl1)
Me.groupControl2.Controls.Add(Me.label4)
Me.groupControl2.Dock = System.Windows.Forms.DockStyle.Fill
Me.groupControl2.Location = New System.Drawing.Point(0, 222)
Me.groupControl2.Name = "groupControl2"
Me.groupControl2.Size = New System.Drawing.Size(386, 274)
Me.groupControl2.TabIndex = 1
Me.groupControl2.Text = "Fast navigation"
'
' lookUpEdit1
'
Me.lookUpEdit1.Location = New System.Drawing.Point(144, 28)
Me.lookUpEdit1.Name = "lookUpEdit1"
Me.lookUpEdit1.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() { New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
Me.lookUpEdit1.Size = New System.Drawing.Size(221, 22)
Me.lookUpEdit1.TabIndex = 2
' Me.lookUpEdit1.EditValueChanged += New System.EventHandler(Me.lookUpEdit1_EditValueChanged);
' Me.lookUpEdit1.QueryPopUp += New System.ComponentModel.CancelEventHandler(Me.lookUpEdit1_QueryPopUp);
'
' label6
'
Me.label6.Location = New System.Drawing.Point(19, 65)
Me.label6.Name = "label6"
Me.label6.Size = New System.Drawing.Size(346, 37)
Me.label6.TabIndex = 3
Me.label6.Text = "Type initial letters of a person name in the edit box to locate the contact recor" & "d."
'
' label5
'
Me.label5.Location = New System.Drawing.Point(19, 28)
Me.label5.Name = "label5"
Me.label5.Size = New System.Drawing.Size(120, 18)
Me.label5.TabIndex = 1
Me.label5.Text = "Search By Name:"
'
' Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.ClientSize = New System.Drawing.Size(386, 496)
Me.Controls.Add(Me.groupControl2)
Me.Controls.Add(Me.groupControl1)
Me.Name = "Form1"
Me.Text = "Incremental search via LookUpEdit"
' Me.Load += New System.EventHandler(Me.Form1_Load);
CType(Me.textEdit1.Properties, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.dateEdit1.Properties.VistaTimeProperties, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.dateEdit1.Properties, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.spinEdit1.Properties, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.listBoxControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.groupControl1, System.ComponentModel.ISupportInitialize).EndInit()
Me.groupControl1.ResumeLayout(False)
CType(Me.groupControl2, System.ComponentModel.ISupportInitialize).EndInit()
Me.groupControl2.ResumeLayout(False)
CType(Me.lookUpEdit1.Properties, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread> _
Shared Sub Main()
Application.Run(New Form1())
End Sub
Private Sub DataBind()
Dim data As DevExpress.Tutorials.XtraEditors.ContactList
data = DevExpress.Tutorials.XtraEditors.ContactList.GetContacts()
textEdit1.DataBindings.Add("EditValue", data, "Name")
dateEdit1.DataBindings.Add("EditValue", data, "PurchaseDate")
spinEdit1.DataBindings.Add("EditValue", data, "PaymentAmount")
dataNavigator1.DataSource = data
listBoxControl1.DataSource = data
listBoxControl1.DisplayMember = "Name"
SetupSearchHelper(data, "Name")
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataBind()
End Sub
Private Sub SetupSearchHelper(ByVal data As IList, ByVal member As String)
lookUpEdit1.Properties.DataSource = data
lookUpEdit1.Properties.DisplayMember = member
lookUpEdit1.Properties.SearchMode = SearchMode.AutoComplete
lookUpEdit1.Properties.Buttons.Clear()
lookUpEdit1.Properties.NullText = "[Type a contact to find]"
lookUpEdit1.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True
lookUpEdit1.Properties.TextEditStyle = TextEditStyles.Standard
End Sub
Private Sub lookUpEdit1_QueryPopUp(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles lookUpEdit1.QueryPopUp
e.Cancel = True
End Sub
Private Sub lookUpEdit1_EditValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lookUpEdit1.EditValueChanged
Dim edit As LookUpEdit = TryCast(sender, LookUpEdit)
Dim data As IList = TryCast(edit.Properties.DataSource, IList)
Dim bm As BindingManagerBase = BindingContext(data)
If edit.EditValue Is Nothing Then
bm.Position = 0
Else
Dim index As Integer = data.IndexOf(edit.EditValue)
If index > -1 Then
bm.Position = index
End If
End If
End Sub
End Class
End Namespace