Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding data to a ToolStripComboBox

C#

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

like image 317
Gilad Naaman Avatar asked May 01 '11 14:05

Gilad Naaman


3 Answers

try

List<string> items = new List<string>{"item1", "item2", "item3"};
toolStripComboBox1.ComboBox.DataSource = items;
like image 155
Bala R Avatar answered Nov 16 '22 05:11

Bala R


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

toolStripComboBox1.ComboBox.BindingContext = this.BindingContext;
like image 30
Angel.Chorbadzhiev Avatar answered Nov 16 '22 05:11

Angel.Chorbadzhiev


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)

like image 1
aolszowka Avatar answered Nov 16 '22 05:11

aolszowka