A component is a class that implements the IComponent interface from the System.ComponentModel namespace. How to implement IComponent is covered in Chapter 9: Design-Time Integration, but any class that implements IComponent becomes a component and can thereafter be integrated with a component hosting environment, such as VS.NET. In VS.NET this integration means that the component can show up on the Toolbar, can be dropped onto a design surface (such as a Form), and can have public properties set and public events consumed in the Property Browser. The chief difference between a control and a component is the location where the interaction with the user occurs (if there is an interaction with the user). A control draws in a container-provided region and takes input from the user. For example, a TextBox is a control. On the other hand, a component may show a UI and take some input from the user , but it doesn't do so in a container-provided region. For example, the OpenFileDialog class is a component that interacts with the user, but in a separate window and not in a region on the form that creates the dialog. The distinction between a component and a control is further evident on a VS.NET design surface itself, as shown in Figure D.1. Figure D.1. Components Versus Controls
|