ComboBoxDemoForm.vb
1: ' Demo of some ComboBox features:
2: ' AutoCompleteMode = Append
3: ' AutoCompletesource = ListItems
4: ' IntegralHeight = False
5: ' MaxDropDownItems = 8
6: ' Initial Items collection = { "one", "two", "three", "four", "five", "six" }
7: '
8: ' Written 3/2010 by Wayne Pollock, Tampa Florida USA
9:
10: Public Class ComboBoxDemoForm
11:
12: ' This code intercepts the Enter key on the ComboBox, and addes
13: ' the user-entered item to the list if it isn't already there:
14:
15: Private Sub ComboBox1_KeyDown(ByVal sender As System.Object, _
16: ByVal e As System.Windows.Forms.KeyEventArgs) _
17: Handles ComboBox1.KeyDown
18: If e.KeyCode = Keys.Return Then
19: Dim newItem As String = ComboBox1.Text
20: If Not ComboBox1.Items.Contains(newItem) Then
21: ComboBox1.Items.Add(ComboBox1.Text)
22: End If
23: End If
24: End Sub
25: End Class