The System.Windows.Forms namespace is a grouping of classes that comprise the Windows Forms technology. The classes in this namespace provide the ability to create Windows applications, which conform to the standard user interface offered by the Windows operating systems.
The classes contained in the Forms namespace can be grouped into several broad categories.
5.2.1 The Control Class
The System.Windows.Forms.Control class is the base class for all the controls used on a Windows Form. A control is a component that has a visual representation at runtime.
The Control class supplies the basic functionality used by all controls. This basic functionality includes methods, properties, and events to cover:
5.2.1.1 Ambient properties
Controls enter into a parent-child relationship on the form. The parent acts as a container for the child control. This relationship should not be confused with the base/derived (generalization/specialization) relationship. For example, a panel may act as a parent control to a button and a listbox, even though button and listbox do not derive from a panel.
Some Control class properties, such as Cursor, Font, BackColor and ForeColor, if not explicitly set for a particular instance of a control, will retrieve the property from their parent controls. They are known as ambient properties. Ambient properties allow a control to appear as its parent. If the control does not have a parent and if the property is not set, then a default value is used.
5.2.1.2 The Control inheritance hierarchy
Each specific control used in Windows Forms will be detailed in Chapters 11 through 17. Figure 5-1 is a list of all the classes that derive from the Control class.
Figure 5-1. Classes derived from Control
5.2.2 The Form Class
All forms in the .NET Framework are defined in a class, specifically one that inherits from the System.Windows.Forms.Form class. The Form object itself is a control that inherits from the System.Windows.Forms.Control class via the ScrollableControl and ContainerControl classes.
Figure 5-2 lists the class hierarchy that contains the Form class and the classes deriving from it.
Figure 5-2. Form class hierarchy
5.2.3 Component Classes
Component classes provide features useful to a Windows application but do not derive from the Control class. They include classes such as ToolTip and ErrorProvider, which provide additional information to the user; timers; menuing classes such as Menu, MenuItem, and ContextMenu; and classes for providing help information, such as Help and HelpProvider. They enable design-time integration of whatever functionality they contain.
5.2.4 CommonDialog Classes
Many applications perform similar functions, such as opening and saving files or selecting fonts. Ever since Windows 3.1, the Windows API has provided standard dialog boxes to perform many of these common operations. Not only does it save the developer from having to reinvent the wheel, but, more importantly, it also makes applications easier to use. Providing a common dialog used by all applications means that users have to learn how to perform each function only once.
The .NET Framework provides several common dialog boxes in the System.Windows.Forms.CommonDialog class, which is a base class for displaying five commonly used Windows dialog boxes. These common dialogs are as follows:
Chapter 6 describes the common dialogs more fully.
Windows Forms and the .NET Framework
Getting Started
Visual Studio .NET
Events
Windows Forms
Dialog Boxes
Controls: The Base Class
Mouse Interaction
Text and Fonts
Drawing and GDI+
Labels and Buttons
Text Controls
Other Basic Controls
TreeView and ListView
List Controls
Date and Time Controls
Custom Controls
Menus and Bars
ADO.NET
Updating ADO.NET
Exceptions and Debugging
Configuration and Deployment