【发布时间】:2011-11-17 22:07:34
【问题描述】:
我有一个 RadMultiColumnComboBox 类型的 ComboBox 控件,我正在尝试搜索并找到一个字符串,然后以编程方式设置选定的索引。
这是我的代码:
// get reference to drop down:
RadMultiColumnComboBox myComboBox = this.BaseFieldControl;
// find and set:
string toFind = "SomeValue";
myComboBox.SelectedIndex = myComboBox .FindExact( toFind );
问题在于,无论我将什么字符串传递给 FindExact,控件的 FindExact 方法都会返回 -1。
当应用程序运行时,我使用即时窗口来测试并输入各种字符串;无论我使用什么字符串,它都会返回 -1。
如果我检查 myComboBox,DataSource 属性中有 10 个项目。
这是 ComboBox 的表示 - 它可能会有所帮助:
【问题讨论】:
标签: c# winforms combobox telerik