C#自定义组合框排序 [英] C# custom combobox sorting
本文介绍了C#自定义组合框排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在combox中可以有自定义排序/显示顺序吗?假设我想在所有其他人之前有一个特殊的值MasterValue。
Is it possible to have a custom sort/display order in a combox ? Say I want a special value "MasterValue" before all the others.
推荐答案
创建一个实现IComparable并覆盖ToString。
Instead of adding strings, create a class that implements IComparable and overrides ToString.
将该类的实例添加到ComboBox中
Add instances of that class to your ComboBox
这篇关于C#自定义组合框排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文