加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C#Combobox将项目移动到列表的底部

发布时间:2020-12-16 05:02:49 所属栏目:百科 来源:网络整理
导读:我需要在组合框项目的底部添加“选择更多…”,就像在SQL 2008服务器选择器上完成一样.试试这样: Liststring srvList = new Liststring(); srvList.Add("ff"); srvList.Add("jj"); srvList.Add("pp"); srvList.Add("Select more..."); ComboBoxServs.Items.A
我需要在组合框项目的底部添加“选择更多…”,就像在SQL 2008服务器选择器上完成一样.试试这样:
List<string> srvList = new List<string>();
        srvList.Add("ff");
        srvList.Add("jj");
        srvList.Add("pp");
        srvList.Add("<Select more...>");
        ComboBoxServs.Items.AddRange(srvList.ToArray<String>());

但是“选择更多…”会出现在项目的顶部.

解决方法

正如 MSDN所说:

If the Sorted property of the ComboBox is set to true,the items are
inserted into the list alphabetically
. Otherwise,the items are
inserted in the order they occur within the array.

尝试将Sorted属性设置为false:

ComboBoxServs.Sorted = false;
    List<string> srvList = new List<string>();
    srvList.Add("ff");
    srvList.Add("jj");
    srvList.Add("pp");
    srvList.Add("<Select more...>");
    ComboBoxServs.Items.AddRange(srvList.ToArray<String>());

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读