I am trying to change from the windows Forms comboBox to the Infragistics one.
But getting an error Cannot apply indexing with the [] to an expression of type 'ValueListItem'
what am I doing wrong?
if (!string.IsNullOrEmpty(location)) { foreach (ValueListItem item in cmbLocation.Items) { if (string.Compare(item[0].ToString(), location, true) != 0) continue; cmbLocation.SelectedItem = item; break; } cbSameProvider.Checked = sameProvider; dtApptDate.Value = DateTime.Now.AddDays(1); //MoveAndExtract() }
Hello Hayley,
Thank you for posting. Looking at the code ,looks like you are missing the ‘DisplayText’ property of the ValueListItem.
Debug your code and test while comparing the values item[0] to location , what are you getting into these? Add item[0].DisplayText in code and test if it fix the issue.
Just to know, if you just want to have a collection of items in your dropdown I would suggest using UltraComboEditor, which has a ValueList property to which you can add the items directly. If you want to have a dropdown with multiple columns, then use UltraCombo by either providing a DataSet/DataTable or a collection of objects that represent your data.
I have also attached a demo sample binding the ValueListItems into an UltraComboEditor, for your reference.Let me know if you need further assistance.
Sincerely,Divya JainAssociate Software Developer
8662.TestSample.zip