C Sharp Programming/The .NET Framework/Windows Forms/Control/Form

The  class 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:

 System.Windows.Forms;   ExampleForm : Form    // inherits from System.Windows.Forms.Form {       Main    {        ExampleForm wikibooksForm = new ExampleForm;        wikibooksForm.Text = "I Love Wikibooks";// specify title of the form        wikibooksForm.Width = 400;              // width of the window in pixels        wikibooksForm.Height = 300;             // height in pixels        Application.Run(wikibooksForm);         // display the form    } }

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.