Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have bound the combobox using Autocomplete.

But I want all lists after typing words compared from any place either from begening or middle

Ex. If list : [Aman ,Raja, Ramn,Pankaj,Amar,Balram]

If I type 'am', it should filter [Aman , Ramn,Amar,Balram] compare from begening or middle.

I have used the code :

C#
AutoCompleteStringCollection col = new AutoCompleteStringCollection();
            int i = 0;
            for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                col.Add(ds.Tables[0].Rows[i][FieldsName].ToString());
            }
            cmb1.AutoCompleteSource = AutoCompleteSource.CustomSource;
            cmb1.AutoCompleteCustomSource = col;
            cmb1.AutoCompleteMode = AutoCompleteMode.Suggest;
            con.Close();



But it compare form left only.Please improve the code.
Posted

1 solution

Your best shot is to write your own function for such that purpose. You can use OnTextChanged event to accomplish this. Here are two links for you to view:
WinForms | C# | AutoComplete in the Middle of a Textbox?[^]
C# AutoComplete[^]

Good luck,
OI
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900