I want to bind a property to a control using Windows Forms Designer.
For example, I have this component:
class MyComponent:Component, INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
private string _strProperty;
[Bindable(true)]
public string StrProperty {
get{
return _strProperty;
}
set {
if (_strProperty != value) {
_strProperty = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("StrProperty"));
}
}
}
}
I drag this component from the toolbox and drop it on a form. The component name is myComponent1. On the same form I have a TextBox control named textBox1.
Now I want to bind textBox1.Text property to myComponent1.StrProperty property.
I know that I can write in code:
textBox1.DataBindings.Add(new Binding("Text", myComponent1, "StrProperty"));
but I want to achieve the same result using the designer. Is it possible? Should I use a BindingSource?