如何在 C# 的组合框中按值查找项目? [英] How do I find an item by value in an combobox in C#?

查看:19
本文介绍了如何在 C# 的组合框中按值查找项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 中,我有变量 a,类型为 string.

In C#, I have variable, a, of type string.

我如何通过comboboxa的值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屋!

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