Resolved search enabler in a combobox

c.vaibhav

Member
Joined
May 12, 2009
Messages
22
Programming Experience
Beginner
Hi All,

1st Query - I have a combobox which has around 10 entries. They are the names of students.

Vaibhav Agarwal
Karan Kabra
Vinay Chhawchharia
Puneet Kabra
.
.
.

I want that when the user types "vai" then it must automatically select Vaibhav Agarwal.

2nd Query - I have another combobox which has around 50 items. They are the names of countries arranged in alphabetical manner. I want that when the user clicks on the drop down and then types "I" then it must go to the countries begining with "I" then when the user types "n" then it must go to countries begining with "In".
I also want in this combobox the feature of selecting the country if it is the last one remaining. For example if the user types "In" and if the combobox has only 1 country begining with "In" then it must automatically get selected.

I hope I am able to explain both of my queries.

Somebody please help.

Thanks,
Vaibhav
 
Last edited:
I have got this code that searches based on just 1 letter..

VB.NET:
    Private Sub CombBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        Dim findString As String = String.Empty
        If (Not e.KeyChar.IsLetterOrDigit(e.KeyChar, 0)) Then Exit Sub
        findString = e.KeyChar
        With ComboBox1
            .SelectedIndex = ComboBox1.FindString(findString)
        End With
        If ComboBox1.SelectedIndex > -1 Then e.Handled = True
    End Sub

I need a more dynamic one..
 
Back
Top