Resolved Is there other AutoComplete methods or events?

Socarsky

Well-known member
Joined
Dec 27, 2012
Messages
173
Location
Jakarta/Indonesia
Programming Experience
Beginner
I have a Textbox on it set to AutoComplete custom collection from a database. Is there an event that fires when a user finds the value they want from the autocomplete list by typing string or choose it in the list by keyboard or mouse click?
I tried normal Textbox Mouse or keyboard events don't work to get at the first choosing by keyboard arrows or mouse click in the list.
 
Last edited:
You can use TextChanged event and check if its .AutoCompleteCustomSource.Contains(.Text)
 
You can use TextChanged event and check if its .AutoCompleteCustomSource.Contains(.Text)
Precious.. Thanks John
It's completely works well for typing and mouse selection..
Here is some code for a sample.
Private Sub txtMagazaKodu_TextChanged(sender As Object, e As EventArgs) Handles txtMagazaKodu.TextChanged
        Try
            If sConn.State = ConnectionState.Closed Then
                sConn.Open()
            End If
        Catch ex As Exception
            MessageBoxEx.EnableGlass = False
            MessageBoxEx.Show("Source: " & sConn.ToString & " Message: " & ex.Message.ToString)
        End Try

        If txtMagazaKodu.AutoCompleteCustomSource.Contains(txtMagazaKodu.Text) Then
            bKaydetControl = True
            btnKaydet.Text = "Değiştir"
            strMagazaKod = txtMagazaKodu.Text
            Using da As New SqlCommand("Select sMagazaAdi from tbMagaza WHERE sMagazaKod= '" & txtMagazaKodu.Text & "'", sConn)
                txtMagazaAdi.Text = CStr(da.ExecuteScalar)
            End Using
        End If
    End Sub
 
Last edited:
Back
Top