Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Controls

A control is a specialized window with specific features and a unique purpose. These are things like buttons, labels, and lists. Table 16.1 introduces each of the standard Windows Forms controls and explains how they're used.

Table 16.1 Windows Forms Controls

Control

How It's Used

Button

Controls that can be clicked to perform some desired action.

CheckBox

Primarily used for displaying a binary state of an object. Clicking the CheckBox causes it to toggle between a checked and unchecked state.

CheckListBox

ListBox with a column of CheckBoxes. These are superior to using normal ListBox semantics where multiple items are selected by using the Ctrl and Shift keys when selecting items. It allows users to select each item they want without worrying about losing all their choices if they forget to hold down the Ctrl or Shift key.

ComboBox

A drop-down list of choices that operates similar to the ListBox. The primary difference is that the ComboBox is more compact and efficient with screen real estate.

DataGrid

An extremely powerful control that permits a program to bind to a data source.

DateTimePicker

Provides a capability to select a date and time without typing.

DomainUpDown

Permits a user to scroll through a list of data items that can only be shown one at a time.

Form

The main window of an application, a dialog, or a multiple-document interface (MDI) child. It provides all the capabilities for hosting child controls.

GroupBox

Houses a group of other controls, often used to encapsulate a group of RadioButtons. It can help organize a form and has a customizable title.

Label

Used to display static text. Labels can also contain images. Although they can be programmed for more functionality, such as reacting to double-clicks, other control types are probably more appropriate for more complex tasks.

LinkLabel

The same as a Label, but it can contain an URL that can be clicked to invoke an Internet connection.

ListBox

Holds selectable lists of data items. When the viewable portion of the ListBox is filled, a scrollbar appears so all of its contained items may be selected.

ListView

Provides capabilities for multiple columns, column headers, column resizing, and list sorting. It can also be configured in four different display modes. More sophisticated than a ListBox.

MessageBox

Provides notifications to users on certain program events. It has a configurable message, title bar, icon, and button.

MonthCalendar

A visual calendar control.

NumericUpDown

The same as a DomainUpDown with the restriction that its contents are numeric.

Panel

Blank forms with little or no decoration that are used primarily for organization and form layout.

PictureBox

Displays an image.

ProgressBar

Used to display the status of an ongoing operation. It has a graphical indicator, set by a program to show the percentage of task completion.

PropertyGrid

For user interface type applications, to set and display a list of properties associated with a certain component.

RadioButton

Mutually exclusive buttons that permit users to make a choice. Also called option buttons.

RichTextBox

An enhanced TextBox control that provides more control over its text. It has the capability of creating Rich Text Format (RTF) files.

ScrollBar

Often used to help position the current location in a document that's too large to fit onscreen or in whatever space is available.

Splitter

-Permit a user to resize multiple portions of a workspace. When the splitter is moved, one portion of the workspace gets larger, and others become smaller.

StatusBar

Performs multiple functions. Primarily it's a place to notify users of a program's status or other forms of current information.

TabControl

User interfaces that appear like file folder tabs. When selected, they open a specific page where the tab and content match.

TextBox

Allows a user to type text. They can be single or multi-line and have many capabilities for text manipulation such as selection, cut, copy, and paste.

Timer

Nonvisual controls that raise events at specified intervals. They can be used for such things as reminders or auto-save operations.

ToolBar

Permits a user to invoke selected operations in a program; similar in functionality to Menus.

ToolTip

Helpful messages that appear when a cursor hovers over a control for a specified amount of time.

TrackBar

Controls that provide a means to establish settings for a certain purpose. They are often handy in specifying the frequency or speed in which an operation should occur.

TrayIcon

Icons displayed on the icon tray of the window's task bar. They usually have different pictures to indicate the current state of a program.

TreeView

Displays items in a hierarchical fashion. It has a root node at the top of the tree and can have multiple branches and nodes. Traditionally it has collapsible branches and is coordinated with another control to display details of selected nodes.


It's evident from Table 16.1 that there is a plentiful supply of graphical components and controls available with Windows Forms. These can be combined to create relatively sophisticated applications. The next section shows how to use C# to build an application with a healthy subset of these components.

  • + Share This
  • 🔖 Save To Your Account