我如何在C#中的组合框找到值的项目? [英] How do I find an item by value in an combobox in C#?
本文介绍了我如何在C#中的组合框找到值的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#中,我有变量, A
,类型字符串
。
In C#, I have variable, a
, of type string
.
我如何按
(我想找到有价值的物件组合框没有显示文本)。 A
在组合框的值找到项目
How do I find item
by value of a
in combobox
(I want find item with value no display text of combobox).
推荐答案
您可以找到它通过使用下面的代码
You can find it by using the following code.
int index = comboBox1.Items.IndexOf(a);
要获得该项目本身,写:
To get the item itself, write:
comboBox1.Items[index];
这篇关于我如何在C#中的组合框找到值的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文