I have a sorted list. When I bind it to a listbox, it does not shows the item in an ordered manner.
territoryListBox.BeginUpdate();
this.Text = ((INamedEntity)_currentList[0]).Name;
territoryListBox.DataSource = _currentList;
territoryListBox.DisplayMember = "Name";
territoryListBox.Sorted = true;
territoryListBox.EndUpdate();
The first item in the list is, say, A. The this.Text shows "A", which is the first item in the list. But the listbox shows:
B
C
A
_currentList is a IList<>
Are you swallowing an exception? When I try this I get (when setting
Sorted
) anArgumentException
:IMO, sort the list first - and bind to that; however, a quick test shows that setting
Sorted
before setting theDataSource
works too - i.e.