> Can a data bound combo box be added to a toolstrip such as a
> bindingnavigator. I can add the toolstrip item, but the databinding
> properties are not present. You also cannot drop a databound text on the
> toolstrip.
You can databind against a ToolstripComboBox, but I'm not sure you can do it
in the designer, and in any case I find doing it in code to be much more
maintainable.
ToolstripComboBox does not derive from Control and therefore does not have
the databinding capabilities you find on a control. It does, however, have a
reference to the ComboBox displayed in its Control property.
ComboBox cb = toolStripComboBox1.Control as ComboBox;
cb.DataSource = CreateKeyValuePairList();
cb.DisplayMember = "Key";
cb.ValueMember = "Value";
cb.DataBindings.Add("SelectedValue", source, "SomeProperty");

Signature
Happy Coding!
Morten Wennevik [C# MVP]
bladecleaver - 18 Aug 2008 12:22 GMT
Sorry, I was a little to quick to post, and forgot to add I am working with
VB. Thanks for the speedy reply, and I will try to figure the C to VB.
bladecleaver
> > Can a data bound combo box be added to a toolstrip such as a
> > bindingnavigator. I can add the toolstrip item, but the databinding
[quoted text clipped - 14 lines]
> cb.ValueMember = "Value";
> cb.DataBindings.Add("SelectedValue", source, "SomeProperty");
Morten Wennevik [C# MVP] - 18 Aug 2008 13:02 GMT
> Sorry, I was a little to quick to post, and forgot to add I am working with
> VB. Thanks for the speedy reply, and I will try to figure the C to VB.
>
> bladecleaver
The difference between C# and VB.Net is very small. Basically drop all ;
and change the order of object declaration :)
Dim cb As ComboBox = ToolStripComboBox1.Control
cb.DataSource = CreateKeyValuePairList()
cb.DisplayMember = "Key"
cb.ValueMember = "Value"
cb.DataBindings.Add("SelectedValue", source, "SomeProperty")

Signature
Happy Coding!
Morten Wennevik [C# MVP]
bladecleaver - 19 Aug 2008 13:40 GMT
Thank you. That did the trick.
> > Sorry, I was a little to quick to post, and forgot to add I am working with
> > VB. Thanks for the speedy reply, and I will try to figure the C to VB.
[quoted text clipped - 9 lines]
> cb.ValueMember = "Value"
> cb.DataBindings.Add("SelectedValue", source, "SomeProperty")