页首Html代码

C#知识点集锦(五)数据绑定,观察者模式

    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

posted @ 2020-12-10 17:30  noigel  阅读(114)  评论(0编辑  收藏  举报
js脚本