Windows Forms


At the core of a C# Windows program is the form. A form encapsulates the basic functionality necessary to create a window, display it on the screen, and receive messages. A form can represent any type of window, including the main window of the application, a child window, or even a dialog box.

When a form is first created, it is empty. To add functionality, you add menus and controls, such as pushbuttons, lists, and check boxes. Thus, you can think of a form as a container for other Windows objects.

When a message is sent to the window, it is translated into an event. Therefore, to handle a Windows message, you will simply register an event handler for that message with the form. Then, whenever that message is received, your event handler is automatically called.

The Form Class

A form is created by instantiating an object of the Form class, or of any class derived from Form. Form contains significant functionality of its own, and it inherits additional functionality. Two of its most important base classes are System.ComponentModel.Component, which was discussed in Chapter 25, and System.Windows.Forms.Control. The Control class defines features common to all Windows controls. Since Form inherits Control, it too is a control. This fact allows forms to be used to create controls. Several of the members of Form and Control are used in the examples that follow.




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net