Chapter 2. Controls
The System.Windows.Forms
namespace defines a class
called Control
. This class is at the heart of all
Windows Forms applications. Any visual element of an
application—whether it is a window, a button, a toolbar, or a
custom user-defined control—is represented by an object of some
class deriving from Control
.
This chapter describes the role played by the
Control
class within the Windows Forms framework,
and examines the basic behavior that all controls inherit from
Control
. It also introduces the classes that
represent the traditional Windows controls.
Windows Forms and the Control Class
Each different type
of user interface element is
represented by a specialized class deriving from
Control
. For example, top-level windows are
represented by the Form
class; each of the
standard Windows control types has a corresponding class (such as
Button
and TreeView
); you can
also define custom controls by creating your own classes. All these
inherit (either directly or indirectly) from the
Control
class.
Because all visual elements derive from Control
,
they share a single implementation of the features common to all
controls. This ensures a certain minimum level of functionality and
guarantees consistent behavior across all control types. The
Control
class defines standard properties, events,
and methods for all the common features of user interface components.
These include size and position, input handling, and appearance.
The Control
class also defines the nature of the relationships ...
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.