Autocomplete match on contains instead startwith

132 Views Asked by At

I search how to use Autocomplete [contains instead of starting with] in winform TextBox but apparently no such result that I want appear.

So I try this code here , no error but it wont appear. Am I missing something?

Private Sub txtSelection_TextChanged(sender As Object, e As EventArgs) Handles txtSelection.TextChanged
        Dim suggestions As New AutoCompleteStringCollection()
        Dim str As String = txtSelection.Text
... 'get dtselection from mysql'
 For i As Integer = 0 To dtSelection.Rows.Count - 1
            If dtSelection.Rows(i).Item(1).ToString().ToLower.Contains(str.ToLower) Then
                suggestions.Add(dtSelection.Rows(i).Item(1).ToString())
            End If
        Next

        txtSelection.AutoCompleteMode = AutoCompleteMode.Suggest
        txtSelection.AutoCompleteSource = AutoCompleteSource.CustomSource
        txtSelection.AutoCompleteCustomSource = suggestions


    End Sub
0

There are 0 best solutions below