Search code examples
sortingtelerikradcombobox

RadComboBox Items Sorting with RadComboBoxSort.None


What happens to RadComboBox's Items after you call:

myCombo.Sort = RadComboBoxSort.None;
myCombo.Items.Sort();

???

Even when sort option is set to None, Items are sorted, but it is not sorted neither by Text nor Value. An items are ordered by random pattern which make no sense.


Solution

  • Use SortItems() method instead of Items.Sort().

    Documentation says that these approaches are equal:

    RadComboBox1.SortItems();
    RadComboBox1.Items.Sort(); 
    

    That is not exactly true. If Sort property is set to None, SortItems leaves items unsorted, but Items.Sort will do something unexpected.