• 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

  • 相关阅读:
    Installing Oracle Database 12c Release 2(12.2) RAC on RHEL7.3 in Silent Mode
    周四测试
    假期生活
    《人月神话》阅读笔记三
    《人月神话》阅读笔记二
    《人月神话》阅读笔记一
    软件进度7
    软件进度6
    软件进度5
    软件进度4
  • 原文地址:https://www.cnblogs.com/noigel/p/14116314.html
Copyright © 2020-2023  润新知