Blog Reader RSS LoveCherry 技术无极限 GEO MVP MS Project开源技术

Binding the Enum to the Dropdown Listbox and Sorting it on Values.

链接:http://www.codeproject.com/KB/combobox/DataBinding_with_Enum.aspx
KEY:
Since SortedList is capable to sort out the item by its "keys" What I did here is for "keys" I have used the Values of Enum and for Values I have used the Text of Enum. Previously It was otherway round I have filled the SortedList with Text of Enum as Keys and Values of Enum as Values of Sorted List. In this case SortedList will return the List with sorted by its Keys. But Since I want "Select" option to be at top with -1 value, What I did is instead of defining SortedList(Of String, Integer) I have defiend SortedList(Of Integer, String) and filled all the Values of Enum as Keys of the SortedList and Text as Values of the SortedList.
下拉框绑定数据源为sortedlist集合,该集合在更改数据时(插入,删除等)能够自动调整集合各元素顺序,根据value项,继承了Icomparable接口,因此我们无需手工改变其顺序。十分方便快捷。

posted @ 2008-05-13 11:18 大宋提刑官 阅读(49) 评论(0)  编辑 收藏 网摘

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
Google站内搜索
[推荐职位]上海盛大网络招聘架构师



China-pub 计算机图书网上专卖店!6.5万品种 2-8折!
近千种 9-95 新二手计算图书火热销售中!
开发者征途系统新作:《设计模式——基于C#的工程化实现及扩展》

相关文章:


相关搜索:
一品梅的小本本 codeproject

相关链接: