原文在此:http://www.codeproject.com/Articles/24656/A-Detailed-Data-Binding-Tutorialhtml
完整译文在此:http://www.cnblogs.com/lichence/archive/2012/02/17/2356001.html数据库
译不下去的笔记在此:编码
System.Windows.Forms.BindingSource是2.0里边的一个新类。赶脚微软想用BindingSource取代之前的CurrencyManager和BindingContext,因此本篇就只讲讲BingdingSource。code
首先:orm
so,DataSource究竟是干吗的?……在现实编码中,一般用BindingSource实例做为Bindings对象们的DataSource属性的值,Binddings[x].DataSource is BindingSource。htm
若是你用数据库,那么这个BindingSource.DataSource一般是DataSet,若是不用数据库,那它极可能是一个自定义类的实例。对象
使用data binding的方法千千万,最经常使用之一:给一个Control的DataSource绑一个BindingSource对象。 blog
能够认为BindingSource是一个二合一的数据源。二合一一般意味着: 事件
控件不一样数据绑定的方式也有不一样: ip
* grid什么的它们的DataBindings属性,即便有东西,也是无用的。这个要注意。
再简化一下也就是两种绑定方式,一个是经过Control.DataSource=,一个是Control.DataBindings.Add()。
经常使用于绑定的属性包括:
Tips: ListView和TreeView的内容是不能绑定的(天怒人怨),它的SelectIndex和Enable这样的属性能够绑定。(天怒人怨)
……
•The latter handler (Binding.Target_Validate) passes the new value through a couple of internal classes, BindToObject and ReflectPropertyDescriptor, the latter of which uses Reflection to actually change the value in the Airplane and then call base.OnValueChanged in its base class, PropertyDescriptor.
这里貌似是讲到TextBox的Validate事件才传新值进行binding的同步。(相关:为何只有textbox lose focus之后,数据才会刷新??)
txtModel.DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
默认值是OnValidated