Chapter 5 - Advanced Control DevelopmentIN THIS CHAPTER
The process of building custom controls has been greatly simplified due to the richness of the base class libraries available in .NET. Already you possess the knowledge and skill necessary to create a wide assortment of controls. All that remains is learning about the services provided by the base class libraries and the VS .NET support for custom control development. In this chapter, all control and designer base classes, interfaces, events, and attributes are discussed at various levels of detail. In this chapter, more details of the base class libraries, designers, and services are explored. Other than learning what services are available for building controls and their associated designers, an understanding of where to begin or what base class should be used is all that needs to be refined.
.NET also introduces the concept of attributes. Attributes are used to provide additional information about classes, properties,
|
Control Base Classes
The Windows Forms library, like custom controls, uses various base classes for both controls and designers. Often it's helpful to have a point of reference in order to proceed with a new project. A hierarchy of the class structure provides an
Figure 5.1. The control class hierarchy.
Regardless of the control you intend to build, there exists a base class from which to begin. Notice that a Form is in fact derived from a control base class, the ContainerControl class to be precise. Each level in the hierarchy provides slightly more features and modifies derived behavior to produce the desired result. Picking the proper base class requires that the expected result and functionality of a new control is properly defined. As a guide, use the following questions to help decide what base class to derive from:
Control base classes are not the only classes that can serve as the starting point for the development of a new control. Consider the
TabPage
control that inherits from the
Panel
control class. In
|