Winform: Two way data binding for textbox

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
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);

How to implement two way databinding in windows form c#

Continue reading...
 
Back
Top