The PropertyManager Class
The PropertyManager class maintains a binding between a data source object's property and a data-bound control property. It differs from CurrencyManager in that it doesn't manage a list of values but it does manage single property values.
lists the methods defined on the base binding manager class and overridden by derived classes.
Table 2: Methods supported by binding managers.
Adds a new item to the underlying list. It has no effect on a PropertyManager object.
Cancels the current edit. The method is supported only if the data source implements the IEditableObject interface. In .NET Framework 1.x, the only class that implements this interface is DataRowView.
Ends the ongoing edit and saves changes.
Get or sets the list of property descriptors for the data source.
Removes an item at the specified position in the underlying list. It has no effect on a PropertyManager object.
Resumes a previously suspended data binding process.
Suspends a data binding process on a data source.
methods allow the temporary suspension and resumption of data binding on a given data source. This typically happens when you want to allow the user to make several edits to data fields before validation occurs. In a complex user interface, it is common that you need to change one field in accordance with a second, but changing the first field may cause temporary inconsistency in the second field until you change that too. Because the data binding process is automatic in nature you would get an exception. To avoid that exception, suspend binding and resume it when all values are consistent again.
The PropertyManager gets into the game when you use simple bindings such as when you link a control's property to a data source columnfor example, you may want the Text
property of a Label to display the LastName
column of the Employees table.
b1 = new Binding("Text", m_dataSet,
The code above creates a Binding object between a property named Text
and the LastName
column in the Employees table within the specified DataSet. The Binding object doesn't know anything about controls. It merely represents a logical property-to-column relationship. The binding becomes effective only when you add the Binding object to the DataBindings
collection of a live control.
When you add a Binding object to the DataBindings
collection of a Windows Forms control, a property binding manager is set up to guarantee that a property with the specified name is given the value of the specified column for the current record. I'll return later to the topic of Binding objects when I show you how to implement data binding with pictures and special data types.