注意:此类在 .NET Framework 2.0 版中是新增的。 windows
封装窗体的数据源。 设计
命名空间:System.Windows.Forms
程序集:System.Windows.Forms(在 system.windows.forms.dll 中) orm
BindingSource 组件有两种用途。首先,它经过提供一个间接寻址层、当前项管理、更改通知和其余服务简化了窗体中控件到数据的绑定。这是经过将 BindingSource 组件附加到数据源,而后将窗体中的控件绑定到 BindingSource 组件来实现的。与数据的全部进一步交互,包括定位、排序、筛选和更新,都经过调用 BindingSource 组件实现。 对象
第二,BindingSource 组件能够做为一个强类型的数据源。一般,基础数据源的类型经过如下机制之一固定: 排序
使用 Add 方法可将某项添加到 BindingSource 组件中。事件
将 DataSource 属性设置为一个列表、单个对象或类型。rem
这两种机制都建立一个强类型列表。BindingSource 支持由其 DataSource 和 DataMember 属性指示的简单数据绑定和复杂数据绑定。 get
BindingSource 提供了用于访问基础数据的成员。经过 Current 属性能够检索当前项,经过 List 属性能够检索整个列表。经过 Current、RemoveCurrent、EndEdit、CancelEdit、Add 和 AddNew 方法可支持对当前项的编辑操做。尽管对于全部基础数据源类型会自动处理当前项管理,但该类公开了许多容许自定义的事件,例如 CurrentItemChanged 和 DataSourceChanged。 it
绑定到 BindingSource 组件的数据源也能够使用 BindingNavigator 类定位和管理,该类提供像 VCR 同样的用户界面 (UI) 用于定位列表中的项。尽管 BindingNavigator 能够绑定到任何数据源,但它被设计为经过其 BindingNavigator.BindingSource 属性与 BindingSource 组件集成。 form
BindingSource 类的默认属性为 DataSource。默认事件为 CurrentChanged。
具体能够参考http://msdn.microsoft.com/zh-cn/library/system.windows.forms.bindingsource(v=vs.80).aspx