I am developing a project in which i have combobox in that there are list of station and i want that when i type the words that will match to that station and that station is selected in combo box

Is the list in combo getting populated from Database tables ?

I am developing a project in which i have combobox in that there are list of station and i want that when i type the words that will match to that station and that station is selected in combo box

try this:

Private Sub Combobox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Combobox1.KeyUp
    '.NET 1.1
        Dim sType As String
        Dim indx As Integer
        Dim iFound As Object
        Dim sFound As String
        Dim sAppend As String

        Select Case e.KeyCode
            Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down, Keys.Back, Keys.Space
                Return
        End Select

        sType = Me.Combobox1.Text
        indx = Me.Combobox1.FindString(sType)

        If indx >= 0 Then
            iFound = Me.Combobox1.Items(indx)
            sFound = Me.Combobox1.GetItemText(iFound)
            sAppend = sFound.Substring(sType.Length)
            Me.Combobox1.Text = sType & sAppend
            Me.Combobox1.SelectionStart = sType.Length
            Me.Combobox1.SelectionLength = sAppend.Length
        End If
    End Sub

sir from this code i didn't get my answer actually
i want that suppose ina list thereare 3 items like
agra
allahabad
aligarh
and when i type ali the aligarh word is on the topmost of the combobox so i select it

sir from this code i didn't get my answer actually
i want that suppose ina list thereare 3 items like
agra
allahabad
aligarh
and when i type ali the aligarh word is on the topmost of the combobox so i select it

the code i provided is an Autocomplete for the combobox so that you need not to select the item instead it automatically complete the combo textbox as you type the word. it is tantamount to drop the list on it, the characters you typed in will be the first word of the combobox index.

In .Net 3.5 it is more easier to do these things.

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.