Previous Section  < Day Day Up >  Next Section

7.1. A Survey of .NET Windows Forms Controls

The System.Windows.Forms namespace contains a large family of controls that add both form and function to a Windows-based user interface. Each control inherits a common set of members from the Control class. To these, it adds the methods, properties, and events that give the control its own distinctive behavior and appearance.

Figure 7-1 shows the inheritance hierarchy of the Windows Forms controls. The controls marked by an asterisk (*) exist primarily to provide backward compatibility between .NET 2.0 and .NET 1.x. Specifically, the DataGrid has been superseded by the DataGridView, the StatusBar by the StatusStrip, and the ToolBar by the ToolStrip. Table 7-1 provides a summary of the more frequently used controls in this hierarchy.

Figure 7-1. Windows Forms control hierarchy

Table 7-1. Selected Windows Forms Controls





Fires an event when a mouse click occurs or the Enter or Esc key is pressed.

Represents a button on a form. Its text property determines the caption displayed on the button's surface.


Permits a user to select one or more options.

Consists of a check box with text or an image beside it. The check box can also be represented as a button by setting:

checkBox1.Appearance =



Displays list of items.

ListBox with checkbox preceding each item in list.


Provides TextBox and ListBox functionality.

Hybrid control that consists of a textbox and a drop-down list. It combines properties from both the TextBox and the ListBox.



Manipulates data in a grid format.

The DataGridView is the foremost control to represent relational data. It supports binding to a database. The DataGridView was introduced in .NET 2.0 and supersedes the DataGrid.


Groups controls.

Use primarily to group radio buttons; it places a border around the controls it contains.


Manages a collection of images.

Container control that holds a collection of images used by other controls such as the ToolStrip, ListView, and TReeView.


Adds descriptive information to a form.

Text that describes the contents of a control or instructions for using a control or form.


Displays a list of items梠ne or more of which may be selected.

May contain simple text or objects. Its methods, properties, and events allow items to be selected, modified, added, and sorted.


Displays items and subitems.

May take a grid format where each row represents a different item and subitems. It also permits items to be displayed as icons.


Adds a menu to a form.

Provides a menu and submenu system for a form. It supersedes the MainMenu control.




Groups controls.

A visible or invisible container that groups controls. Can be made scrollable.

FlowPanelLayout automatically aligns controls vertically or horizontally.

TablePanelLayout aligns controls in a grid.


Contains a graphic.

Used to hold images in a variety of standard formats. Properties enable images to be positioned and sized within control's borders.


Depicts an application's progress.

Displays the familiar progress bar that gives a user feedback regarding the progress of some event such as file copying.


Permits user to make one choice among a group of options.

Represents a Windows radio button.


Provides a set of panels that indicate program status.

Provides a status bar that is used to provide contextual status information about current form activities.


Accepts user input.

Can be designed to accept single- or multi-line input. Properties allow it to mask input for passwords, scroll, set letter casing automatically, and limit contents to read-only.


Displays data as nodes in a tree.

Features include the ability to collapse or expand, add, remove, and copy nodes in a tree.

This chapter lacks the space to provide a detailed look at each control. Instead, it takes a selective approach that attempts to provide a flavor of the controls and features that most benefit the GUI developer. Notable omissions are the DataGridView control, which is included in the discussion of data binding in Chapter 12, "Data Binding with Windows Forms Controls," and the menu controls that were discussed in Chapter 6, "Building Windows Forms Applications."

    Previous Section  < Day Day Up >  Next Section