By How2Prog - 4/10/2013
You may have noticed in the search engines that they are bringing all the words that begins with the letter that you typed in the search box, and you may wonder how I can design a program using this feature.
Image from Google engine:
To make an auto complete combo box in vb.net. Create a new windows application project, and add a combobox to your form.
Edit the combobox items, by clicking to the arrow on the top:
Fill the shown list with items by your choice:
Now, go to the KeyUp event, and tape this code:
'index of taped text
Dim index As Integer
'text found
Dim found As String
'text written
Dim actual As String'to avoid these keys
Dim bo As Boolean = e.KeyCode = Keys.Back Or e.KeyCode = Keys.Left _
Or e.KeyCode = Keys.Right Or e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down _
Or e.KeyCode = Keys.Delete Or e.KeyCode = Keys.PageDown _
Or e.KeyCode = Keys.PageUp Or e.KeyCode = Keys.End _
Or e.KeyCode = Keys.Home
If bo = True Then
Exit Sub
End If
actual = Me.ComboBox1.Text
index = Me.ComboBox1.FindString(actual)
'this condition means that there is a result
If index > -1 Then
found = Me.ComboBox1.Items(index).ToString
Me.ComboBox1.SelectedIndex = index
Me.ComboBox1.SelectionStart = actual.Length
Me.ComboBox1.SelectionLength = found.Length
Me.ComboBox1.DroppedDown = True
End If
To Download this project, click here:
http://how2prog.com/Downloads/Auto%20Complete%20(VB.Net).rar
For more free tutorials and projects, visit us at:
http://www.how2prog.com
=========================================
|
|