通过键入在comboBox中选择一个项目 [英] Selecting an item in comboBox by typing

查看:69
本文介绍了通过键入在comboBox中选择一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框,其中包含数百个项目。用户必须能够在组合框中键入文本。用户键入文本时,必须选择或列出以键入的值开头的项目。用户必须能够连续输入。我的ComboBox DropDownStyle是DropDownList

I've a combobox that has hundreds item in it. User must be able to type the text into the combobox . While the user is typing the text, the item that starting with the typed value must be selected or listed. The user must be able type continuously. My ComboBox DropDownStyle is DropDownList

例如:
通过键入在comboBox中选择名称时,它只允许一个字母。因此,如果我输入 A,它将跳到以 A开头的第一个字母。当我连续键入组合框时,所选项目会根据当前按键而变化。如果我按 As,组合框将查看以 s开头的项目。

Eg: While selecting a name in comboBox by typing, it only allows one letter. So if I type "A" it will jump to the first letter starting with "A". when i type continuously the combo box selected item changes according to the current keypress. if i press "As", combobox viewing the items starting with "s".

我正在使用Win Forms。

I'm using Win Forms.

预先感谢。.

推荐答案

comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;

这篇关于通过键入在comboBox中选择一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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