开发者

vb.net using SortedDictionary as combobox datasource

I have a combobox which 开发者_运维百科i am binding to a sortedDictionary list, so it displays in ascending order. My question is, I need to display "--Select--" as the first option. Is there any way to either: 1) add another item besides for the datasource or 2) add an unsorted item to the top of the sortedDictionary

any other ideas welcome as well :)

TIA


In the ascii sorting sequence, 11 characters ! " # $ % & ' ( ) + , come before -.

If it is not likely that your list of entries will start with any one of these characters, then adding your "-- Select --" item and resorting the list will result in "-- Select --" appearing at the top of the list.


A bit complicated solution would be writing a wrapper class which will put the --Select-- option at the beginning of your list. I'd like to know how exactly are you binding to the SortedDictionary though, I don't think that combo box accepts a dictionary for its data source.


Use the following code in a procedure that you use to create the sortedDictionary list. The main idea is to use a UNION the rest you can modify as appropriate

    SELECT
    '0' as yourCodeValue,
    '---Select ---' as yourValueDescription

    UNION 

    SELECT     
    yourCodeValue,
    yourValueDescription
    FROM  youTable
    ORDER By yourValueDescription
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜