How can I bind a custom property of a windows form to a second property?
- by jeroko
I want to bind a custom property of a windows form to a second property, so when I update the former the latter gets the same value.
This is the simplest example of what I'm trying to do:
public partial class Form2 : Form
{
public string MyTargetProperty { get; set; }
public string OtherProperty { get; set; }
public Form2()
{
InitializeComponent();
this.DataBindings.Add("MyTargetProperty", this, "OtherProperty");
}
private void button1_Click(object sender, EventArgs e)
{
MyTargetProperty = "test";
Console.WriteLine("OtherProperty " + OtherProperty);
}
}
When I click button1 I should be able to see that 'OtherProperty' has the same value as 'MyTargetProperty'. Am I doing something wrong? Do I miss something?