Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
System.Windows.Forms Namespace

Updated: November 2007

The System.Windows.Forms namespace contains classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows operating system.

The following table shows the classes in System.Windows.Forms namespace grouped into categories.

Class category

Details

  • Control, User Control, and Form

Most classes within the System.Windows.Forms namespace derive from the Control class. The Control class provides the base functionality for all controls that are displayed on a Form. The Form class represents a window within an application. This includes dialog boxes, modeless windows, and Multiple Document Interface (MDI) client and parent windows. You can also create your own controls by deriving from the UserControl class.

  • Menus and Toolbars

Windows Forms contains a rich set of classes for creating your own custom toolbars and menus with modern appearance and behavior (look and feel). ToolStrip, MenuStrip, ContextMenuStrip, and StatusStrip can be used to create toolbars, menu bars, context menus, and status bars, respectively.

  • Controls

The System.Windows.Forms namespace provides a variety of control classes that you can use to create rich user interfaces. Some controls are designed for data entry within the application, such as TextBox and ComboBox controls. Other controls display application data, such as Label and ListView. The namespace also provides controls for invoking commands within the application, such as Button. The WebBrowser control and managed HTML classes, such as HtmlDocument, let you display and manipulate HTML pages within your managed Windows Forms application. The MaskedTextBox control is an advanced data entry control that lets you define masks that automatically accept or reject user input. Additionally, you can use the PropertyGrid control to create your own Windows Forms Designer that displays the designer-visible properties of the controls.

  • Layout

Several important classes in Windows Forms help control the layout of controls on a display surface, such as a form or control. FlowLayoutPanel lays out all the controls it contains in a serial manner, and TableLayoutPanel lets you define cells and rows for laying out controls in a fixed grid. SplitContainer divides your display surface into two or more adjustable parts.

  • Data and Data Binding

Windows Forms defines a rich architecture for binding to data sources such as databases and XML files. The DataGridView control provides a customizable table for displaying data, and lets you customize cells, rows, columns, and borders. The BindingNavigator control represents a standardized way to navigate and work with data on a form; BindingNavigator is frequently paired with the BindingSource control to move through data records on a form and interact with them.

  • Components

Besides controls, the System.Windows.Forms namespace provides other classes that do not derive from the Control class but still provide visual features to a Windows-based application. Some classes, such as ToolTip and ErrorProvider, extend the capabilities or provide information to the user. With the Help and HelpProvider classes, you can display Help information to a user of your applications.

  • Common Dialog Boxes

Windows provides several common dialog boxes that you can use to give your application a consistent user interface when performing tasks such as opening and saving files, manipulating the font or text color, or printing. The OpenFileDialog and SaveFileDialog classes provide the functionality to display a dialog box that lets the user locate and enter the name of a file to open or save. The FontDialog class displays a dialog box to change elements of the Font used by your application. The PageSetupDialog, PrintPreviewDialog, and PrintDialog classes display dialog boxes that enable the user to control aspects of printing documents. For more information about printing from a Windows-based application, see the System.Drawing.Printing namespace. Besides the common dialog boxes, the System.Windows.Forms namespace provides the MessageBox class for displaying a message box that can display and retrieve data from the user.

There are several classes within the System.Windows.Forms namespace that provide support to the classes mentioned in the previous summary. Examples of the supporting classes are enumerations, event argument classes, and delegates used by events within controls and components.

Caution:

Classes within the Windows Forms namespace are not supported for use within a Windows service. Trying to use these classes from within a service may produce unexpected problems, such as diminished service performance and run-time exceptions.

If you are using .NET Framework version 1.1 or .NET Framework 1.0 and you must make your Windows Forms application support Windows XP visual styles, make sure that you set the FlatStyle property of your controls to FlatStyle..::.System and include a manifest with your executable file. A manifest is an XML file that is included either as a resource within your application executable file or as a separate file that resides in the same directory as the executable file. For an example of a manifest, see the Example section for the FlatStyle enumeration. For more information about how to use the visual styles available in Windows XP, see "Using Windows XP Visual Styles in the User Interface Design and Development" in the MSDN Library. By default visual styles are enabled for the .NET Framework versions 1.1, 1.2, and 2.0.

  ClassDescription
AccessibleObject Provides information that accessibility applications use to adjust an application's user interface (UI) for users with impairments.
AmbientProperties Provides ambient property values to top-level controls.
Application Provides static methods and properties to manage an application, such as methods to start and stop an application, to process Windows messages, and properties to get information about an application. This class cannot be inherited.
ApplicationContext Specifies the contextual information about an application thread.
AutoCompleteStringCollection Contains a collection of to strings use for the auto-complete feature on certain Windows Forms controls.
AxHost Wraps ActiveX controls and exposes them as fully featured Windows Forms controls.
AxHost..::.AxComponentEditor Provides an editor that uses a modal dialog box to display a property page for an ActiveX control.
AxHost..::.ClsidAttribute Specifies the CLSID of an ActiveX control hosted by an AxHost control.
AxHost..::.ConnectionPointCookieInfrastructure. Connects an ActiveX control to a client that handles the control’s events.
AxHost..::.InvalidActiveXStateException The exception that is thrown when the ActiveX control is referenced while in an invalid state.
AxHost..::.State Encapsulates the persisted state of an ActiveX control.
AxHost..::.StateConverterInfrastructure. Converts AxHost..::.State objects from one data type to another.
AxHost..::.TypeLibraryTimeStampAttribute Specifies a date and time associated with the type library of an ActiveX control hosted by an AxHost control.
BaseCollection Provides the base functionality for creating data-related collections in the System.Windows.Forms namespace.
Binding Represents the simple binding between the property value of an object and the property value of a control.
BindingCompleteEventArgs Provides data for the BindingComplete event.
BindingContext Manages the collection of BindingManagerBase objects for any object that inherits from the Control class.
BindingManagerBase Manages all Binding objects that are bound to the same data source and data member. This class is abstract.
BindingManagerDataErrorEventArgs Provides data for the DataError event.
BindingNavigator Represents the navigation and manipulation user interface (UI) for controls on a form that are bound to data.
BindingsCollection Represents a collection of Binding objects for a control.
BindingSource Encapsulates the data source for a form.
Button Represents a Windows button control.
ButtonBase Implements the basic functionality common to button controls.
ButtonBase..::.ButtonBaseAccessibleObject Provides information that accessibility applications use to adjust an application's user interface for users with disabilities.
ButtonRenderer Provides methods used to render a button control with or without visual styles. This class cannot be inherited.
CacheVirtualItemsEventArgs Provides data for the CacheVirtualItems event.
CheckBox Represents a Windows CheckBox.
CheckBox..::.CheckBoxAccessibleObjectInfrastructure. Provides information about the CheckBox control to accessibility client applications.
CheckBoxRenderer Provides methods used to render a check box control with or without visual styles. This class cannot be inherited.
CheckedListBox Displays a ListBox in which a check box is displayed to the left of each item.
CheckedListBox..::.CheckedIndexCollection Encapsulates the collection of indexes of checked items (including items in an indeterminate state) in a CheckedListBox.
CheckedListBox..::.CheckedItemCollection Encapsulates the collection of checked items, including items in an indeterminate state, in a CheckedListBox control.
CheckedListBox..::.ObjectCollection Represents the collection of items in a CheckedListBox.
Clipboard Provides methods to place data on and retrieve data from the system Clipboard. This class cannot be inherited.
ColorDialog Represents a common dialog box that displays available colors along with controls that enable the user to define custom colors.
ColumnClickEventArgs Provides data for the ColumnClick event.
ColumnHeader Displays a single column header in a ListView control.
ColumnHeaderConverter Provides a type converter to convert ColumnHeader objects from one type to another.
ColumnReorderedEventArgs Provides data for the ColumnReordered event.
ColumnStyle Represents the look and feel of a column in a table layout.
ColumnWidthChangedEventArgs Provides data for the ColumnWidthChanged event.
ColumnWidthChangingEventArgs Provides data for the ColumnWidthChanging event.
ComboBox Represents a Windows combo box control.
ComboBox..::.ChildAccessibleObjectInfrastructure. Provides information about the ComboBox control to accessibility client applications.
ComboBox..::.ObjectCollection Represents the collection of items in a ComboBox.
ComboBoxRenderer Provides methods used to render a combo box control with visual styles. This class cannot be inherited.
CommonDialog Specifies the base class used for displaying dialog boxes on the screen.
ContainerControl Provides focus-management functionality for controls that can function as a container for other controls.
ContentsResizedEventArgs Provides data for the ContentsResized event.
ContextMenu Represents a shortcut menu. Although ContextMenuStrip replaces and adds functionality to the ContextMenu control of previous versions, ContextMenu is retained for both backward compatibility and future use if you choose.
ContextMenuStrip Represents a shortcut menu.
Control Defines the base class for controls, which are components with visual representation.
Control..::.ControlAccessibleObject Provides information about a control that can be used by an accessibility application.
Control..::.ControlCollection Represents a collection of Control objects.
ControlBindingsCollection Represents the collection of data bindings for a control.
ControlEventArgs Provides data for the ControlAdded and ControlRemoved events.
ControlPaint Provides methods used to paint common Windows controls and their elements. This class cannot be inherited.
ConvertEventArgs Provides data for the Format and Parse events.
CreateParams Encapsulates the information needed when creating a control.
CurrencyManager Manages a list of Binding objects.
Cursor Represents the image used to paint the mouse pointer.
CursorConverter Provides a type converter to convert Cursor objects to and from various other representations.
Cursors Provides a collection of Cursor objects for use by a Windows Forms application.
DataFormats Provides static, predefined Clipboard format names. Use them to identify the format of data that you store in an IDataObject.
DataFormats..::.Format Represents a Clipboard format type.
DataGrid Displays ADO.NET data in a scrollable grid. The DataGridView control replaces and adds functionality to the DataGrid control; however, the DataGrid control is retained for both backward compatibility and future use, if you choose.
DataGrid..::.HitTestInfo Contains information about a part of the System.Windows.Forms..::.DataGrid at a specified coordinate. This class cannot be inherited.
DataGridBoolColumn Specifies a column in which each cell contains a check box for representing a Boolean value.
DataGridColumnStyle Specifies the appearance, text formatting, and behavior of a System.Windows.Forms..::.DataGrid control column. This class is abstract.
DataGridColumnStyle..::.CompModSwitchesInfrastructure. Contains a TraceSwitch that is used by the .NET Framework infrastructure.
DataGridColumnStyle..::.DataGridColumnHeaderAccessibleObject Provides an implementation for an object that can be inspected by an accessibility application.
DataGridPreferredColumnWidthTypeConverter Converts the value of an object to a different data type.
DataGridTableStyle Represents the table drawn by the System.Windows.Forms..::.DataGrid control at run time.
DataGridTextBox Represents a TextBox control that is hosted in a DataGridTextBoxColumn.
DataGridTextBoxColumn Hosts a TextBox control in a cell of a DataGridColumnStyle for editing strings.
DataGridView Displays data in a customizable grid.
DataGridView..::.DataGridViewAccessibleObject Provides information about the DataGridView control to accessibility client applications.
DataGridView..::.DataGridViewControlCollection Represents a collection of controls contained on a DataGridView.
DataGridView..::.DataGridViewTopRowAccessibleObject Provides information about a row of DataGridViewColumnHeaderCell objects to accessibility client applications.
DataGridView..::.HitTestInfo Contains information, such as the row and column indexes, about a specific coordinate pair in the DataGridView control. This class cannot be inherited.
DataGridViewAdvancedBorderStyle Contains border styles for the cells in a DataGridView control.
DataGridViewAutoSizeColumnModeEventArgs Provides data for the DataGridView..::.AutoSizeColumnModeChanged event.
DataGridViewAutoSizeColumnsModeEventArgs Provides data for the AutoSizeColumnsModeChanged event.
DataGridViewAutoSizeModeEventArgs Provides data for the