System.Windows.Forms.BindingManagerBase Class

Manages all System.Windows.Forms.Binding objects that are bound to the same data source and data member. This class is abstract.

See Also: BindingManagerBase Members


public abstract class BindingManagerBase


The System.Windows.Forms.BindingManagerBase enables the synchronization of data-bound controls on a Windows Form that are bound to the same data source. (For more information about simple binding a control to a data source, see the System.Windows.Forms.Binding class.) For example, suppose that a form contains two System.Windows.Forms.TextBox controls that are bound to the same data source but to different columns. The data source might be a System.Data.DataTable that contains customer names, while the columns might contain the first and last names. The two controls must be synchronized in order to display the correct first and last names together for the same customer. The System.Windows.Forms.CurrencyManager, which inherits from the System.Windows.Forms.BindingManagerBase class, accomplishes this synchronization by maintaining a pointer to the current item in the data source. The System.Windows.Forms.TextBox controls are bound to the current item so they display the information for the same row. When the current item changes, the System.Windows.Forms.CurrencyManager notifies all the bound controls so that they can refresh their data. Furthermore, you can set the BindingManagerBase.Position property to specify the row in the System.Data.DataTable that the controls point to. To determine how many rows exist in the data source, use the BindingManagerBase.Count property.

The System.Windows.Forms.CurrencyManager is necessary because data sources do not necessarily maintain a current-item pointer. For instance, arrays and ArrayList objects can be data sources, but they do not have a property that returns the current item. To get the current item, use the BindingManagerBase.Current property.

The System.Windows.Forms.PropertyManager also inherits from the System.Windows.Forms.BindingManagerBase, and it is used to maintain the current property of an object, rather than the property of a current object in a data source. For this reason, trying to set the BindingManagerBase.Position or BindingManagerBase.Count property for a System.Windows.Forms.PropertyManager has no effect.

To create a System.Windows.Forms.BindingManagerBase, use the System.Windows.Forms.BindingContext class, which returns either a System.Windows.Forms.CurrencyManager or a System.Windows.Forms.PropertyManager, depending on the data source being managed.

Solutions programmers are encouraged to bind controls directly to a System.Windows.Forms.BindingSource component, which acts as both a data source and data connector to the actual target data source. System.Windows.Forms.BindingSource greatly simplifies both simple and complex data binding, including managing currency between the control and its target.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0,