Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Combobox move item to bottom of the list

I need to add "Select more..." to the bottom of the combobox items, like it done on SQL 2008 servers selector. Trying like this:

        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>());

But "Select more..." appears at the top of items.

like image 532
ArisRS Avatar asked Oct 22 '22 15:10

ArisRS


1 Answers

As MSDN says:

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.

Try to set Sorted property to 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>());
like image 158
Andrey Gordeev Avatar answered Oct 24 '22 10:10

Andrey Gordeev