Reputation: 2634
I have a ComboBox control of type RadMultiColumnComboBox and I'm trying to search and find a string and then set the selected index programmatically.
Here is my code:
// get reference to drop down:
RadMultiColumnComboBox myComboBox = this.BaseFieldControl;
// find and set:
string toFind = "SomeValue";
myComboBox.SelectedIndex = myComboBox .FindExact( toFind );
The problem is that the controls FindExact method is returning -1 not matter what string I pass into FindExact.
While the app is running I use the Immediate window to test and enter various strings; no matter what I string I use, it returns -1.
If I inspect myComboBox there are 10 items in the DataSource property.
Here is a representation of the ComboBox - it may help:
Upvotes: 0
Views: 9490
Reputation: 4908
you can cast datasource to original type and find index from DataSource:
var data=(List<YourType)myComboBox.DataSource;
myComboBox.SelectedIndex=data.FindIndex(p=>p.Text=="SomeValue");
Upvotes: 4