C# 自定义组合框排序 [英] C# custom combobox sorting

查看:17
本文介绍了C# 自定义组合框排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在组合框中自定义排序/显示顺序?假设我想要一个特殊值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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆