public partial class Form1 : Form { public Form1() { InitializeComponent(); } MyData _myData = null; private void Form1_Load(object sender, EventArgs e) { _myData = new MyData(); textBox1.DataBindings.Add("Text", _myData, "TheValue", false, DataSourceUpdateMode.OnPropertyChanged); textBox2.DataBindings.Add("Text", _myData, "TheValue", false, DataSourceUpdateMode.Never); } private void textBox3_TextChanged(object sender, EventArgs e) { _myData.TheValue = textBox3.Text; } } public class MyData : INotifyPropertyChanged { private string _theValue = string.Empty; public string TheValue { get { return _theValue; } set { _theValue = value; PropertyChanged(this, new PropertyChangedEventArgs("TheValue")); } } public event PropertyChangedEventHandler PropertyChanged; }
http://blog.sina.com.cn/s/blog_7b60d05f0101rr0d.html
观察者模式
https://www.cnblogs.com/xmfdsh/p/4047114.html