st *_*nmn 28
您可以使用以下代码找到它.
int index = comboBox1.Items.IndexOf(a);
Run Code Online (Sandbox Code Playgroud)
要获取项目本身,请写:
comboBox1.Items[index];
Run Code Online (Sandbox Code Playgroud)
小智 10
您应该在FindStringExact()的组合框控件上看到一个方法,该方法将搜索显示成员并返回该项目的索引(如果找到).如果未找到则返回-1.
//to select the item if found:
mycombobox.SelectedIndex = mycombobox.FindStringExact("Combo");
//to test if the item exists:
int i = mycombobox.FindStringExact("Combo");
if(i >= 0)
{
//exists
}
Run Code Online (Sandbox Code Playgroud)