Binding data to a ToolStripComboBox

前端 未结 3 1676
滥情空心
滥情空心 2021-01-04 07:20

C#

I have ToolStripComboBox control. Is there a way to bind this ToolStripComboBox to a list?

相关标签:
3条回答
  • 2021-01-04 07:52

    try

    List<string> items = new List<string>{"item1", "item2", "item3"};
    toolStripComboBox1.ComboBox.DataSource = items;
    
    0 讨论(0)
  • 2021-01-04 07:52

    If you're finding this and you want the ComboBox to dynamically you'll need to make sure that the data structure that you have set as the Data Source implements IBindingList one such structure is BindingList(T)

    0 讨论(0)
  • 2021-01-04 07:58

    You might also need to set ComboBox.BindingContext to Form's BindingContext property:

    toolStripComboBox1.ComboBox.BindingContext = this.BindingContext;
    
    0 讨论(0)
提交回复
热议问题