Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Auto Complete ComboBox in VB.Net


Auto Complete ComboBox in VB.Net

Author
Message
How2Prog
How2Prog
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12
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



=========================================

http://www.how2prog.com



How2Prog.Com Is a wonderful space to learn programming easily, includes many of the open source projects in many different programming languages (Visual Basic.Net, C#.Net, Java EE, ...)
Edited
4/10/2013 by How2Prog
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search