键入时,如何在comboBox(dropDownStyle-> simple)上选择索引? [英] How do you select index on comboBox(dropDownStyle -> simple) as you type?
问题描述
当您键入在comboBox列表中找到的匹配项时,如何在列表中选择索引?
例如,假设我通过某种方式在comboBox中找到了正确的索引,那么如何选择列表中的特定索引?
comboBox.SelectedIndex = index .....不起作用.列表只是向上或向下移动,但不会在我找到匹配项时突出显示/被选中.
另外,我只想选择完全匹配.如果键入的内容不匹配,则将没有选择.
How do you select an index in the list as you type for the match found in the comboBox list?
Let''s assume for example that I found the right index in the comboBox by some means, how do I select the specific index in the list?
comboBox.SelectedIndex = index.....won''t work. The list just moves up or down but won''t highlight/get selected as I found the match.
Another thing, I want to select the complete match only. If there is no match as I type, then there will be no selection.
推荐答案
您好,
假设您想要组合框中的第三项
那么你可以做到这一点:
combobox1.selectedindex = 2
这将选择第三项.
并获取所选项目,请执行以下操作:
字符串str = combobox1.selecteditem;
hi there,
suppose you want the third item in the combobox
then u can do this:
combobox1.selectedindex=2
this will select the third item.
and to get the selected item, do this:
string str = combobox1.selecteditem;
这篇关于键入时,如何在comboBox(dropDownStyle-> simple)上选择索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!