Components Defined


A component is a class that implements the IComponent interface, located in the System.ComponentModel namespace. Any class that implements IComponent can be integrated with a componenthosting environment, such as VS05. In this way, components like ErrorProvider show up on the Toolbox and can be dragged onto a form, as shown in Figure 9.1.

Figure 9.1. Dragging an ErrorProvider Component onto a Form


Essentially, components are reusable, configurable classes. Consequently, they do not provide native support for user interaction via a form, such as by exposing a UI that's hosted by a form or handling keyboard and mouse input. Intrinsic support for UI interaction is provided by controls, which are covered in Chapter 10: Controls. This distinction is further reinforced by the location where components are hosted on a form, specifically in an area known as the nonvisual design surface, or component tray, shown in Figure 9.2.

Figure 9.2. Components Hosted on Nonvisual Design Surface (a.k.a. the Component Tray)


Two kinds of components do expose UIs in special situations. First, there are components like ErrorProvider and Tool tip that show their UIs infrequently enough that it doesn't make sense for them to be hosted on a form next to other controls that are usually visible all the time. Second, the behavior of components like OpenFileDialog and SaveFileDialog requires the creation of an entirely new window. However, the UIs presented by these components do not come under the purview of the host form.

Some controls, such as tool strips, also manifest themselves on the nonvisual design surface as pseudocomponents. When the Visible property on a tool strip is set to false, it actually becomes hidden on the form at design time, thereby precluding developers from selecting and configuring it. However, this ability is given back via the nonvisual design surface.

Either way, all components reside on the nonvisual design surface.




Windows Forms 2.0 Programming
Windows Forms 2.0 Programming (Microsoft .NET Development Series)
ISBN: 0321267966
EAN: 2147483647
Year: 2006
Pages: 216

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net