如何在 C# 的组合框中按值查找项目? [英] How do I find an item by value in an combobox in C#?
本文介绍了如何在 C# 的组合框中按值查找项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 C# 中,我有变量 a
,类型为 string
.
In C#, I have variable, a
, of type string
.
我如何通过combobox
中a
的值find item
(我想找到没有combobox显示文本的值的item).
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屋!
查看全文