G
Guest
I'm trying to do basic data binding to a ToolStripComboBox but the
items aren't being populated. If i put a break point i can see that
the data source has information in it but it's not being displayed. So
the DataSource does have the BindingList associated with it. This is for a
ContextMenuStrip; a toolstrip seems to work ok.
private BindingList<string> _binding = new BindingList<string>(new
string[] { "Hello", "Goodbye" });
protected override void OnLoad(...) {
// i also tried going tdirectly to toolStripComboBox1.ComboBox
ComboBox cBox = toolStripComboBox1.Control as ComboBox;
toolStripComboBox1.Sorted = false;
cBox.Sorted = false;
cBox.DataSource = _binding;
this._cbo2.ComboBox.DataSource = _binding;
comboBox1.DataSource = _binding;
}
Googlin', the only thing i can find is a mention that if the data
source is an array, and you try to sort the combo box, it will cause
the items not to display. So i set the sorted properties to false for
the hell of it.
The only way i got it to work was to add the control to the form's/user
control's control collection, do the data bindnig, then add it to a
ToolStripControlHost. If i don't perform that step it doesn't work. The
problem with this approach is that when i add new items to the binding list
it won't update the combobox(or listbox) even if i call refresh on the
currency manager or call ResetBindings on the BindingList.
Am i doing something completely stupid here?
items aren't being populated. If i put a break point i can see that
the data source has information in it but it's not being displayed. So
the DataSource does have the BindingList associated with it. This is for a
ContextMenuStrip; a toolstrip seems to work ok.
private BindingList<string> _binding = new BindingList<string>(new
string[] { "Hello", "Goodbye" });
protected override void OnLoad(...) {
// i also tried going tdirectly to toolStripComboBox1.ComboBox
ComboBox cBox = toolStripComboBox1.Control as ComboBox;
toolStripComboBox1.Sorted = false;
cBox.Sorted = false;
cBox.DataSource = _binding;
this._cbo2.ComboBox.DataSource = _binding;
comboBox1.DataSource = _binding;
}
Googlin', the only thing i can find is a mention that if the data
source is an array, and you try to sort the combo box, it will cause
the items not to display. So i set the sorted properties to false for
the hell of it.
The only way i got it to work was to add the control to the form's/user
control's control collection, do the data bindnig, then add it to a
ToolStripControlHost. If i don't perform that step it doesn't work. The
problem with this approach is that when i add new items to the binding list
it won't update the combobox(or listbox) even if i call refresh on the
currency manager or call ResetBindings on the BindingList.
Am i doing something completely stupid here?