如何根据输入的内容过滤组合框的内容? [英] How can I filter the contents of a combo box based on what's been typed?
问题描述
我们有一个包含100多个项目的组合框.
We have a combo box with more than 100 items.
当我们在组合框中输入字符时,我们想过滤掉项目.例如,如果我们输入"ac"并单击下拉选项,那么我们希望它仅显示以"ac"开头的项目.
We want to filter out the items as we enter characters in combo box. For example if we entered 'ac' and click on the drop down option then we want it to display items starting with 'ac' only.
我该怎么做?
推荐答案
也许您会更高兴使用操作系统内置的自动完成功能.我之前在此处为进行了概述.创建一个IAutoComplete
对象,将其连接到组合框的列表并编辑控件,操作系统将在用户键入时自动显示一个潜在匹配项的下拉列表.您无需自己调整组合框的列表.
Maybe you'd be happier using the autocompletion features built in to the OS. I gave an outline of how to do that here previously. Create an IAutoComplete
object, hook it up to your combo box's list and edit control, and the OS will display a drop-down list of potential matches automatically as the user types. You won't need to adjust the combo box's list yourself.
这篇关于如何根据输入的内容过滤组合框的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!