本文介绍了Winform:文本框的双向数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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 /论坛/ SQLSERVER / EN-US / 072524f6-1bdf-4ed4-AC30-c7c06442ba46 /如何做 - 实施 - 双向-绑定式窗口形式-C?论坛= winformsdatacontrols
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
推荐答案
这篇关于Winform:文本框的双向数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!