To set selectedindex by value I have to use a 2 step process like this or is there a better way?
1st method:
Dim myValueListItem As ValueListItem = cboFrequency.Items.ValueList.FindByDataValue(FrequencyCode) If myValueListItem IsNot Nothing Then cboFrequency.SelectedIndex = cboFrequency.FindStringExact(myValueListItem.DisplayText) End If
2nd method:
cboFrequency.SelectedIndex = cboFrequency.Items.IndexOf(cboFrequency.Items.
ValueList.FindByDataValue(FrequencyCode))
Hello Peter,
This seems fine to me. What is bothering you, it is a simple and accurate approach.
You have a method called FindByString/FindByExactString that's 1 pass to return the index.
Not sure why there is no method like this:
cboFrequency.SelectedIndex = cboFrequency.FindByDataValue(FrequencyCode))
Currently I am using this but as you can see it's a 2 pass and a little difficult to discover.