windows in a Windows Forms application
are represented by objects of some type deriving from the
Form class. Of course,
Control, as do all classes that
represent visual elements, so we have already seen much of what it
can do in the previous chapter. But we will now look at the features
Form class adds.
You will rarely use the
directly—any forms you define in your application will be
represented by a class that inherits from
Adding a new form in Visual Studio .NET simply adds an appropriate
class definition to your project. We will examine how it structures
these classes when generating new forms, and we will look at how it
cleans up any resource used by the form when it is destroyed. Then,
we will consider the different types of forms. Finally, we will look
at extender properties. These provide a powerful way of extending the
behavior of all controls on a form to augment the basic
Most forms are designed using the Forms Designer in Visual Studio .NET. This is not an essential requirement—the designer just generates code that you could write manually instead. It is simply much easier to arrange the contents of a form visually than it is to write code to do this.
When you add a new form to a project, a new class definition is
created. The Designer always uses the same structure for the source
code of these classes. They begin with
fields in C# and
Friend fields in VB to ...