Hello Friends
I am VB.NET Programmer and currently working on a project where i have to search from combobox.
I am retreving the data from database(MS ACCESS) and loading it in combobox at form load event

I have set the following properties in combobox for search :
1. AutoCompleteMode TO Suggest
2. AutoCompleteSource TO ListItems
3. Sorted = True

I want to search in combobox including the keyword
eg: Data in combobox are :
Raj Kumar
Rohit Kamble
Kumar Shanti

Suppose when i type Kum in combobox it should show 2 entries ie. Raj Kumar and Kumar Shanti
It should show me search results including the keyword
Kindly Help me Thank You

5 Years
Discussion Span
Last Post by QVeen72

Autocomplete will only show entries that begin with what is already entered. "Raj Kumar" will not show up because it does not begin with "Kum".


fill the combobox from database , . . . And use the Query " select * from tbl where name like '% "& Cmb.Text &"%' " on TextChanged Event on the combobox.


One suggestion. The following code uses a listbox control (lbxChoices) and a textbox control (txtChoice). As you enter text into txtChoice, the listbox is modified to contain only those entries containing the given string. Click on an entry in the listbox to replace txtChoice.Text with the selection. Just populate "words" with an appropriate list.

Public Class Form1

    Private words() As String = {"the", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"}

    Private Sub txtChoice_TextChanged(sender As Object, e As System.EventArgs) Handles txtChoice.TextChanged
        lbxChoices.Items.AddRange(Filter(words, txtChoice.Text))
    End Sub

    Private Sub lbxChoices_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles lbxChoices.SelectedIndexChanged
        txtChoice.Text = DirectCast(sender, ListBox).Text
    End Sub

End Class

Edited by Reverend Jim


i am taking values from database
I load in Combobox so when user types any keyword i get the required field



What you can do is.. Add one more ListBox, and add all the names from database into that list box..
In Change event of combobox, clear combobox.. and loop thru the Listbox, add items to combo box with like condition...


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.