Custom Component Designers
Visual Studio .NET enables controls to customize the Forms Designer. New commands can be added in the property grid. Resize and move drag operations can be altered, and mouse handling within the control can be customized. Design-time adornments may be added (adornments are editing features such as resize handles). Hit testing can be provided for nonrectangular controls. Controls may elect to act as containers of child controls. Controls may even modify the way that properties are presented in the property panel. All these facilities revolve around supplying a custom component designer.
A component designer is a class associated with the control class,
whose job is to handle design-time interaction with the development
environment. It must derive from the
ControlDesigner
class,
which is defined in the
System.Windows.Forms.Design
namespace. (In fact,
any component may have a designer, not just a control. A non-visual
component’s designer derives from the
ComponentDesigner
class, which is defined in the
System.ComponentModel.Design
namespace.)
Tip
The terminology is unfortunate—there are three designers involved at design time:
The Forms Designer (the visual editing environment provided by Visual Studio .NET for building Windows Forms applications)
The control’s custom designer class
The developer who is designing the form
To avoid ambiguity, in this book, the Forms Designer is always referred to with a capital D. A designer with a lower case D refers to the ...
Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.