I probably have a very simple problem, but could not find a solution. I have a problem with the property binding to a ToolStripLabel. A Label is bound to COM port value in App.Config.
If I bind the property for a System.Windows.Forms.Label label, the update of Text-Property by changing the COM Port works fine as it is supposed to. But when the label is IN ToolStrip (System.Windows.Forms.ToolStripLabel), the label is not updated by changing the value for COM Port at runtime.
It will be changed only by new start of Application.
In the picture there is a current settings of PropertyBinding to ApplicationSettings.
I've already tried:
- Application.DoEvents()
- toolStrip.Update()
- toolStrip.Refresh()
- toolStrip.Invalidate()
Nothing makes difference. Does anyone have an idea what the problem could be?
Greetings, Sasha
The ToolStripLabel Component doesn't implement DataBindings, as the Label Control does (that's why you can see a Label Control update its Text when the current setting is changed). When you add
PropertyBindingsto theTextproperty through the Designer, the Text is just set to theProperties.Defaultsetting selected (you can see that in theDesigner.csfile).You can build your own ToolStripLabel that implements IBindableComponent, decorate it with ToolStripItemDesignerAvailability flags that allow the ToolStrip or StatusStrip to acknowledge the existence of this custom Component, so you can add it directly from the selection tool.
Add a
PropertyBindingto the Text property and now, when the Setting changes, the Text is updated. You can see in theDesigner.csfile that a DataBinding has been added.