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

Recommended Answers

All 7 Replies

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".

Yeah it does not shows so any alternatives ?

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.Clear()
        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

how about in combox??

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

Hi,

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...

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.