Where Are We

This chapter has covered all the major data-binding interfaces that you might need to either implement or consume. I presented them from the perspective of describing the contract that the interface represents, followed by the details represented by the interface's members. I used a few examples to describe and demonstrate the more complex concepts, and also described some things in terms of the implementations and use of the interfaces as they exist in the .NET Framework controls and collections that you should already be getting familiar with, such as the DataView and DataGridView. There are a few more interfaces at work behind the scenes, such as the IBindableComponent interface implemented on the base Control class of Windows forms. But because you really shouldn't have to mess with these interfaces directly, I didn't bother going into any detail on them.

Some key takeaways from this chapter are:

• I List is the minimum interface implementation that lets you bind a collection directly to a control.

® The BindingSource component can iterate through a collection that only implementdEnumerable and add the items to its own internal list collection, so Enumerable is sufficient to support data binding through aBindingSource.

® IBindingList is the minimum support you should strive for on a data-bound collection, because it allows synchronization between bound controls when items are added or removed from the collection.

® INotifyPropertyChanged is important for rich data binding on custom objectsit lets the Ul stays up to date when the objects are modified through programmatic code.

® PropertyDescriptor objects are the key to runtime getting and setting of property values on a data object, regardless of whether that object is a row in a data table or a custom business object in a custom collection.

To really gain a full appreciation of these interfaces and how to use them, you have to assume one of two perspectivesthat of the interface's consumer or that of the interface's implementer. The consumer could be any form of client code that interacts with the collection, but will often be data-bound controls. The implementer will be a collection, a data object, or a control.

The next two chapters further explore these different perspectives. Chapter 8 shows how to implement custom data-bound controls and uses some of the interfaces defined in this chapter to consume the data to which they are bound. Chapter 9 shows how to implement custom collections and objects that support rich data binding, and how to implement all of the collection- and object-level interfaces described in this chapter.

4 PREY

0 0

Post a comment