John (Yiannis) Toutountzoglou
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....
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
yeap .....union...is a good choise....thanks..
ASKER
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