Binding a generic List to a ComboBox

后端 未结 6 1532
轻奢々
轻奢々 2020-12-16 13:07

I have a ComboBox and I want to bind a generic List to it. Can anyone see why the code below won\'t work? The binding source has data in it, but it won\'t fill the ComboBox

6条回答
  •  醉梦人生
    2020-12-16 13:33

    this is the simple way (it works correctly):

    List my_list = new List();
    my_list.Add("item 1");
    my_list.Add("item 2");
    my_list.Add("item 3");
    my_list.Add("item 4");
    my_list.Add("item 5");
    comboBox1.DataSource = my_list;
    

提交回复
热议问题