C Sharp Programming/The .NET Framework/Windows Forms

System.Windows.Forms
To create a Windows desktop application we use the library represented by namespace. Some commonly used classes in this namespace include:
 * Control - generic class from which other useful classes, like, and others listed below are derived
 * Form - this is the base class for the program window. All other controls are placed directly onto a or indirectly on another container (like  or ) that ultimately resides on the . When automatically created in Visual Studio, it is usually subclassed as.
 * Button - a clickable button
 * TextBox - a singleline or multiline textbox that can be used for displaying or inputting text
 * RichTextBox - an extended that can display styled text, e.g. with parts of the text colored or with a specified font. RichTextBox can also display generalized RTF document, including embedded images.
 * Label - simple control allowing display of a single line of unstyled text, often used for various captions and titles
 * ListBox - control displaying multiple items (lines of text) with ability to select an item and to scroll through it
 * ComboBox - similar to, but resembling a dropdown menu
 * TabControl and TabPage - used to group controls in a tabbed interface (much like tabbed interface in Visual Studio or Mozilla Firefox). A contains a collection of  objects.
 * DataGrid - data grid/table view

Form class
The class (System.Windows.Forms.Form) is a particularly important part of that namespace because the form is the key graphical building block of Windows applications. It provides the visual frame that holds buttons, menus, icons, and title bars together. Integrated development environments (IDEs) like Visual C# and SharpDevelop can help create graphical applications, but it is important to know how to do so manually:

The example above creates a simple Window with the text "I Love Wikibooks" in the title bar. Custom form classes like the example above inherit from the class. Setting any of the properties, , and is optional. Your program will compile and run successfully, if you comment these lines out, but they allow us to add extra control to our form.

Events
An event is an action being taken by the program when a user or the computer makes an action (for example, a button is clicked, a mouse rolls over an image, etc.). An event handler is an object that determines what action should be taken when an event is triggered.

Controls
The Windows Forms namespace has a lot of very interesting classes. One of the simplest and important is the class. A form is the key building block of any Windows application. It provides the visual frame that holds buttons, menus, icons and title bars together. Forms can be modal and modalless, owners and owned, parents and children. While forms could be created with a notepad, using a form editor like VS.NET, C# Builder or Sharp Develop makes development much faster. In this lesson, we will not be using an IDE. Instead, save the code below into a text file and compile with command line compiler.