See Also: Form Members
A System.Windows.Forms.Form is a representation of any window displayed in your application. The System.Windows.Forms.Form class can be used to create standard, tool, borderless, and floating windows. You can also use the System.Windows.Forms.Form class to create modal windows such as a dialog box. A special kind of form, the multiple-document interface (MDI) form, can contain other forms called MDI child forms. An MDI form is created by setting the Form.IsMdiContainer property to true. MDI child forms are created by setting the Form.MdiParent property to the MDI parent form that will contain the child form.
Using the properties available in the System.Windows.Forms.Form class, you can determine the appearance, size, color, and window management features of the window or dialog box you are creating. The Control.Text property allows you to specify the caption of the window in the title bar. The Form.Size and Form.DesktopLocation properties allow you to define the size and position of the window when it is displayed. You can use the Control.ForeColor color property to change the default foreground color of all controls placed on the form. The Form.FormBorderStyle, Form.MinimizeBox, and Form.MaximizeBox properties allow you to control whether the form can be minimized, maximized, or resized at run time.
In addition to properties, you can use the methods of the class to manipulate a form. For example, you can use the Form.ShowDialog method to show a form as a modal dialog box. You can use the Form.SetDesktopLocation(int, int) method to position the form on the desktop.
The events of the System.Windows.Forms.Form class allow you to respond to actions performed on the form. You can use the Form.Activated event to perform operations such as updating the data displayed in the controls of the form when the form is activated.
You can use a form as the starting class in your application by placing a method called Main in the class. In the Main method add code to create and show the form. You will also need to add the STAThread attribute to the Main method in order for the form to run. When the starting form is closed, the application is also closed.
If you set the Control.Enabled property to false before the System.Windows.Forms.Form is visible (for example, setting Control.Enabled to false in the TLA#tla_visualstu designer), the minimize, maximize, close, and system buttons remain enabled. If you set Control.Enabled to false after the System.Windows.Forms.Form is visible (for example, when the Load event occurs), the buttons are disabled.