Populating a ComboBox using C#

后端 未结 10 1394
不知归路
不知归路 2020-12-02 15:55

I would like to populate a combobox with the following:

Visible item / Item Value

English / En

Italian / It

Spainish / Sp 

etc...         


        
10条回答
  •  北海茫月
    2020-12-02 16:19

    Simple way is:

    Dictionary dict = new Dictionary()
    {
        {"English ","En" },
        {"Italian  ","It" },
        {"Spainish  ","Sp " }
    };
    
    combo.DataSource = new BindingSource(dict, null);
    combo.DisplayMember = "Key";
    combo.ValueMember = "Value";
    

提交回复
热议问题