See Also: BindingSource Members
The System.Windows.Forms.BindingSource component serves many purposes. First, it simplifies binding controls on a form to data by providing currency management, change notification, and other services between Windows Forms controls and data sources. This is accomplished by attaching the System.Windows.Forms.BindingSource component to your data source using the BindingSource.DataSource property. For complex binding scenarios you can optionally set the BindingSource.DataMember property to a specific column or list in the data source. You then bind controls to the System.Windows.Forms.BindingSource. All further interaction with the data is accomplished with calls to the System.Windows.Forms.BindingSource component. For examples on how the System.Windows.Forms.BindingSource can simplify the binding process, see How to: Bind Windows Forms Controls to DbNull Database Values and How to: Handle Errors and Exceptions that Occur with Databinding. Navigation and updating of the data source is accomplished through methods such as BindingSource.MoveNext, BindingSource.MoveLast, and BindingSource.Remove(object). Operations such as sorting and filtering are handled through the BindingSource.Sort and BindingSource.Filter properties. For more information on using sorting and filtering with the System.Windows.Forms.BindingSource, see How to: Sort and Filter ADO.NET Data with the Windows Forms BindingSource Component.
In addition, the System.Windows.Forms.BindingSource component can act as a strongly typed data source. Typically the type of the underlying data source is fixed through one of the following mechanisms:
Set the BindingSource.DataSource property to a list, single object, or type.
Both of these mechanisms create a strongly-typed list. For more information on how to use the System.Windows.Forms.BindingSource to bind to a type, see How to: Bind a Windows Forms Control to a Type. You can also use the System.Windows.Forms.BindingSource to bind your controls to a factory object. For more information on how to do this, see How to: Bind a Windows Forms Control to a Factory Object.
Because a System.Windows.Forms.BindingSource handles both simple and complex data sources, terminology is problematic. Within this class documentation, the term list refers to a data collection within the hosted data source, and item denotes a single element. When discussing functionality associated with complex data sources, the equivalent terms table and row are used.
System.Windows.Forms.BindingSource provides members for accessing the underlying data. The current item can be retrieved through the BindingSource.Current property, and the entire list can be retrieved through the BindingSource.List property. Editing operations are supported on the current item through BindingSource.Current and the BindingSource.RemoveCurrent, BindingSource.EndEdit, BindingSource.CancelEdit and BindingSource.Add(object) and BindingSource.AddNew methods. Although currency management is handled automatically for all underlying data source types, this class exposes a number of events, such as BindingSource.CurrentItemChanged and BindingSource.DataSourceChanged, that allow for customization.
Data sources that are bound to a System.Windows.Forms.BindingSource component can also be navigated and managed with the System.Windows.Forms.BindingNavigator class, which provides a VCR-like user interface (UI) for navigating items within a list. Although System.Windows.Forms.BindingNavigator can be bound to any data source, it was designed to integrate with a System.Windows.Forms.BindingSource component through its BindingNavigator.BindingSource property.
Many of the members of the System.Windows.Forms.BindingSource class operate on the underlying list represented by the BindingSource.List property and simply refer their operation to the underlying list. Therefore, when the System.Windows.Forms.BindingSource is bound to a custom implementation of IList, the exact behavior of these members may differ from the behavior described in the class documentation. For example, the BindingSource.RemoveAt(int) method calls IList.RemoveAt(int). The System.Windows.Forms.BindingSource documentation describes the BindingSource.RemoveAt(int) method with the understanding that the IList.RemoveAt(int) method for the underlying IList is correctly implemented.