complete-reference-vb_net_82
complete-reference-vb_net_82
A form is your application's little claim of screen space that you will use to communicate with users. Your
form will occupy either a portion of the screen or all of it. Forms are typically rectangular in shape and can be
made to shrink or grow to any sizefrom the size of a dime or less, to the size of the screen when the form is
fully maximized. Forms can be solid, opaque, or invisible. With advanced support of the Windows XP and
.NET Server operating systems, forms can also now be any shape.
You use the form to present information to the user and to accept input from the user. This is achieved by
placing familiar objects on the form, with which the user interacts to send and receive information to and from
the application.
UI developers arrange the controls on the form in an aesthetic and productive manner by exposing the various
properties of the input/output controls placed on the form. The properties of the controls define their behavior
and affect how the user interacts with the application.
As the interface developer, you will also spend a substantial amount of your time behind the form's UI,
implementing its code. Controls do not magically hook into existing functionality you have written; you still
have to "wire up" the UI to the back end and business logic and hook up the events to the event handlers and
event listeners. This wiring involves capturing events generated by the controls on the form, such as text being
entered, mouse clicks, button clicks, scrolling through lists, collapsing and expanding trees, and so on. The
events communicate with interested objects that monitor the form for services they need to perform, such as
sending data to a database and retrieving data from the database.
A Form Is an Object
As previously stated many times, a class is a template or a blueprint for an object. The .NET Form class is
such a blueprint for the form object that you instantiate. Form classes can also be extended by you. This
means you can easily inherit from existing framework or custom forms to add functionality or modify existing
behavior. In other words, when you add a form to your project, you can choose to inherit from the standard
Form class or from a custom base Form class you may have already developed. The form hierarchy of
classes is a perfect example of how inheritance is used as the foundation for all specializations of classes in an
OO framework. Form objects are also controls, because the standard form provided by the framework
ultimately inherits from its parent Control class.
Chapter 9 presented a concise introduction to the Form class in the discussion of inheritance and aggregation.
We saw then how a form can be created entirely in the Code Editor. But Visual Studio makes it far easier to
use the Windows Forms Designer to create and modify forms. Later in this section, we will discuss the steps
to take to kick off a UI project with the creation of your main form, and any collateral forms used by your
application.
The System.Windows.Forms namespace contains the collection of classes used for creating Windows−based
UI applications. The classes in this namespace can be grouped as follows:
• Control
• UserControl
• Form
• Controls
566