Link to home
Start Free TrialLog in
Avatar of John (Yiannis) Toutountzoglou
John (Yiannis) ToutountzoglouFlag for Greece

asked on

Different Autocomplete CustomSource for the same Textbox

I have one Textbox  as a search Control . Is it possible to have 2 different autocomplete custom sources for the same control?
The one source includes only numbers and the other only letters
I have in mind  Key press event to separate digit from letters but is this a good choise....
'Autocomplete code
Private Sub AutocompleteSearch1()
        Dim AutoLastnameconn As New SqlConnection(ProjectConnectionString)
        Dim AutoLastnameda As SqlDataAdapter = New SqlDataAdapter("SELECT Key_Personnel,ASMA FROM Personnel ORDER BY ASMA", AutoLastnameconn)
        Dim AutoLastnameds As DataSet = New DataSet
        Dim acLastname As New AutoCompleteStringCollection
        AutoLastnameda.Fill(AutoLastnameds, "Personnel")
        For Each AutoLAstnamedr As DataRow In AutoLastnameds.Tables("Personnel").Rows
            acLastname.Add(AutoLAstnamedr.Item("Lastname").ToString)
        Next
        TextBox1.AutoCompleteCustomSource = acLastname
        TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John (Yiannis) Toutountzoglou

ASKER

Yes i understand that...There might be an event on how chose between the one source and the other...
ifthe user press a number then the autocomplete must change to populate the codes for example..if there is a letter then the other source must populate..
i have 2 diiferent subs like the one above.
Thank you
mmmm thinking now clearly...there is a logic on your suggestion...let me try it...
It will automatically filter the data and will show which is closer.
as you have numeric data and other is alphabetic/letters so you will never be mixed.
yeap .....union...is a good choise....thanks..