Any interactive application must have at least one window through
which to present its user interface. In the Windows Forms framework,
all such top-level application windows are represented by objects
whose types derive from the
Form class. As with
any user interface element, the
inherits from the
Control class, but it adds
windowing features, such as management of the window border and
interaction with the Windows taskbar. All Windows Forms applications
have at least one class derived from
In this chapter we will examine the structure of a typical Windows Forms application and the way its constituent forms are created. We will look at the programming model for forms, and the way that the Visual Studio .NET Forms Designer uses this model. We will look in detail at the relationship between a form and the controls it contains, and also at the relationships that can exist between forms. The mechanisms underpinning the automatic layout features described in the previous chapter will be examined, and we will see how to use these to add our own custom layout facilities.
All Windows Forms applications have something in common, regardless of whether they are created with Visual Studio .NET or written from scratch:
They all have at least one form, the main application window.
They all need to display that form at start up.
They must shut down correctly at the appropriate time.
This section describes the basic ...