How can I bind a custom property of a windows form to a second property?
        Posted  
        
            by jeroko
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by jeroko
        
        
        
        Published on 2010-04-16T08:50:53Z
        Indexed on 
            2010/04/16
            8:53 UTC
        
        
        Read the original article
        Hit count: 312
        
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?
© Stack Overflow or respective owner