开发者

Binding data to a ToolStripComboBox

开发者 https://www.devze.com 2023-03-01 17:04 出处:网络
C# I have ToolStripComboBox control. I开发者_JS百科s there a way to bind this ToolStripComboBox to a list?try

C#

I have ToolStripComboBox control. I开发者_JS百科s there a way to bind this ToolStripComboBox to a list?


try

List<string> items = new List<string>{"item1", "item2", "item3"};
toolStripComboBox1.ComboBox.DataSource = items;


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

toolStripComboBox1.ComboBox.BindingContext = this.BindingContext;


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号