views:

7

answers:

1

I have a object myObject.Name in a Form1 with a textBox1 In the Form1_Load I do:

this.TextBox1.DataBindings.Add("Text", myObject, "Name");

When validating the textBox I have myObject.Name changed. This is OK.

Now I modify internally in myObject _name = "changed value", but myTextBox text will not change. so... how to do it on both directions, from and to the textBox1?

+1  A: 

Your object needs to implement INotifyPropertyChanged so that the data binding knows that your object changed.

Lucero
...and then the next line after `_name = "changed value"` must be something like `PropertyChanged(this,new PropertyChangedEventArgs("Name"));`. Basically, you are creating an event that gets fired whenever a property changes, but *you have to implement the firing of that event in your setters*.
Jay
thanks! So simple :)
serhio
Thanks Jay for the implementation details :)
Lucero