用了combobox 绑定了数据源 tIDBindingSource 绑定字段 id 显示字段也是id程序当中想判断一下某个值是否在 combobox中用了各种方法蛋疼最简单的 comboBox1.Items.Contains(str)
无法判断出来。
然后我想直接在数据源判断也出不来正确结果,为什么呢
MessageBox.Show(tIDBindingSource.Contains("123").ToString());
无法判断出来。
然后我想直接在数据源判断也出不来正确结果,为什么呢
MessageBox.Show(tIDBindingSource.Contains("123").ToString());
item是object类型吧
试试用int
comboBox1.Items.Contains(int)
combox有三种DropDownStyle可能与这个有关
哎。感觉这方法太不专业了。。关于之前那个问题到底应该怎么比较啊
List<string> list = new List<string>();
for (int i = 0; i < iCount; i++)
{
list.Add(this.comboBox1.GetItemText(this.comboBox1.Items[i]));
}MessageBox.Show(list.Contains("1005").ToString());
combox = new ComboBox();
combox.Items.AddRange(new object[4]{"小赵","小钱","小孙","小李"});
if (combox.Items.Contains("小李"))
{
MessageBox.Show(combox.Items.IndexOf("小李").ToString());
}
comboBox1.Items.Contains(new ...item("aaaa")) new一个项试试