在Windows c#中自动完成组合框:从任何位置过滤 [英] Autocomplete combobox in windows c# : Filter from any location

查看:56
本文介绍了在Windows c#中自动完成组合框:从任何位置过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用自动完成功能绑定了组合框。



但是我希望所有列表在输入单词后从任何地方比较来自begening或middle



Ex。如果列表:[Aman,Raja,Ramn,Pankaj,Amar,Balram]



如果我输入''am'',它应该过滤[Aman,Ramn,Amar ,Balram]比较begening或middle。



我用过的代码:



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 :

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.

推荐答案

最好的办法就是为此目的编写自己的函数。您可以使用 OnTextChanged 事件来完成此操作。以下是两个供您查看的链接:

WinForms | C#|在文本框中间自动完成? [ ^ ]

C#自动完成 [ ^ ]



祝你好运,

OI
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


这篇关于在Windows c#中自动完成组合框:从任何位置过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆