How to data bind a ToolStripComboBox

Normally, the ToolStripComboBox doesn’t have any properties for data binding. But you can still data bind this combobox with the method I describe here. Since the ToolStripComboBox hosts a Control that inherits from ComboBox, you can type cast to a ComboBox and do the data binding.

In this example I will bind the ToolStripComboBox to an ArrayList which consists of objects of the type ColorTypes.

So, lets get started. First create the ColorType class:

Second, in the Form that hosts the TollStripComboBox, create an ArrayList of the objects. In the Load method, cast the ToolStripComboBox to a ComboBox and do the data binding. And finally, in the SelectedIndexChanged event for the ToolStripComboBox, type cast to a ComboBox and read out the SelectedValue property.