none
Winform: Two way data binding for textbox RRS feed

  • Question

  • public partial class Form1 : Form, INotifyPropertyChanged
        {
            public event PropertyChangedEventHandler PropertyChanged;
    
            public Form1()
            {
                InitializeComponent();
                textBox1.DataBindings.Clear();
                textBox1.DataBindings.Add("Text", this, "Title", true, DataSourceUpdateMode.OnPropertyChanged);
            }
    
            string _title ="";
            public string Title
            {
                get { return _title; }
                set
                {
                    _title = value;
                    if (Title == _title)
                    {
                        PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Title"));
                    }
                }
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                this.Title = "hello";
            }
        }

    tell me the meaning of this line 

    textBox1.DataBindings.Add("Text", this, "Title", true, DataSourceUpdateMode.OnPropertyChanged);

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/072524f6-1bdf-4ed4-ac30-c7c06442ba46/how-to-implement-two-way-databinding-in-windows-form-c?forum=winformsdatacontrols

    • Edited by Sudip_inn Saturday, January 12, 2019 6:33 PM
    Saturday, January 12, 2019 6:20 PM

All replies