我正在使用带有组合的数据绑定(bind)来在下拉列表中显示我的对象。数据绑定(bind)后,组合框需要自动按字母顺序对其中的数据进行排序。如何才能做到这一点?我希望逻辑是通用的并直接应用于组合框,而不是应用于绑定(bind)到它的对象。
最佳答案
数据绑定(bind)组合框无法直接排序。您必须对基础数据源进行排序。这是来自 MSDN:
Attempting to set the Sorted property on a data-bound control raises an
ArgumentException. You must sort the data using the underlying data model.
因此您也许可以使用 SortedList 作为绑定(bind)源。
关于winforms - 排序组合框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11560943/