![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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. |
#4
| |||
| |||
|
|
"bladecleaver" wrote: 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"); -- Happy Coding! Morten Wennevik [C# MVP] |
#5
| |||
| |||
|
|
"bladecleaver" wrote: 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"); -- Happy Coding! Morten Wennevik [C# MVP] |
#6
| |||
| |||
|
|
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 |

#7
| |||
| |||
|
|
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 |

#8
| |||
| |||
|
|
"bladecleaver" wrote: 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") -- Happy Coding! Morten Wennevik [C# MVP] |
#9
| |||
| |||
|
|
"bladecleaver" wrote: 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") -- Happy Coding! Morten Wennevik [C# MVP] |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |