保持ListBox排序,但始终将特定条目固定在顶部 [英] Keep ListBox sorted, but with a particular entry always pinned to the top

查看:116
本文介绍了保持ListBox排序,但始终将特定条目固定在顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含国家(从Active Directory中获取)的列表框.我希望对列表进行排序,但我也希望一个条目全部"位于最顶部.

I have a ListBox filled with Countries (which I take from the Active Directory). I want the list to be sorted, but also I want one entry "All" to be at the very top.

我该怎么做?

推荐答案

如果要在后面的代码中绑定数据,则可以在索引0处插入Listitem.

If you are binding the data in code behind you can insert a Listitem at index 0.

ListItem myItem=new ListItem("ALL","value");
myListbox.Items.Insert(0, myItem);

这篇关于保持ListBox排序,但始终将特定条目固定在顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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