根据在文本框中输入的文本过滤listview [英] filter listview based on text entered in textbox

查看:91
本文介绍了根据在文本框中输入的文本过滤listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在listview控件中,我有一个文本框,我想在其中使用自动过滤功能.例如,如果我在文本框内输入kis,那么我希望所有以kis开头的记录都将被显示(类似于Google自动过滤功能).

In a listview control, I have a textbox which I want to use autofiltering in. For instance, if I enter kis into the textbos then I would expect that all records that start with kis would be displayed (similar to the way that Google autofiltering works). Does anybody have any pointers on where I should start?

推荐答案

您需要处理文本框控件的TextChanged事件,然后在该事件处理程序中执行一个在数据集上进行linq查询,以查找所有以键入的字母开头的条目,并将其放在列表框中.

请记住,这仅在您的数据集只有少量记录的情况下才可行.
You need to handle the TextChanged event for the textbox control, and in that event handler, perform a linq query on your dataset to find all entries that start with whatever letters have been typed, and put them in the listbox.

Keep in mind that this is only going to practical if your dataset only has a small number of records.


这篇关于根据在文本框中输入的文本过滤listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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