且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将 Winforms 控件数据绑定到可为空类型的***方法?

更新时间:2022-05-20 18:10:10

在上面引用的文章的评论部分,其中一位海报提出了一个简单的解决方案.

In the comments section of the article referenced above one of the posters comes up with a simple solution.

而不是绑定:

textBox1.DataBindings.Add("Text", myClass, "MyTextProperty");

绑定:

textBox1.DataBindings.Add("Text", myClass, "MyTextProperty", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty);