As you can see, Windows forms are made up of Windows controls. The controls have properties, which describe the state of the object, and events, which describe the actions that happen to the control. Table 20-1 describes the common controls. Tables 20-2 and 20-3 show the properties and events of controls.
|
Control Name |
Description |
|---|---|
|
Button |
Used to execute a path of code that realizes the intent of the button |
|
Calendar |
Provides a picture of a calendar in which you can select a date and month |
|
Check Box |
Provides an on/off, yes/no, include/exclude capability |
|
Combo Box |
Combines the features of a Text Box and a List Box; the three styles are drop-down (simple), always display list, and drop-down complex |
|
Date/Time Picker |
A Text Box that allows a user to choose a date and time from a calendar view |
|
Group Box |
Allows you to group other controls that have a common purpose |
|
Label |
Displays text |
|
List Box |
Displays an array of strings that a user can choose from |
|
Main Menu |
Creates a main menu |
|
Picture |
Allows you to place a picture on a form |
|
Pointer |
The icon used for the mouse pointer |
|
Progress |
Allows you to display the progress of a specific action |
|
Radio Button |
Allows the user to make a single selection from a group |
|
Horizontal Scroll Bar |
Allows the user to scroll left and right |
|
Vertical Scroll Bar |
Allows the user to scroll up and down |
|
Text Box |
Allows the user to enter text |
|
Timer |
This control is not visible and is used to start specific events |
|
Property |
Description |
|---|---|
|
Name |
The programmatic name of the control |
|
AutoCheck |
When true, a radio button changes state automatically when clicked |
|
AutoScale |
When true, the form scales with the screen font |
|
AutoScroll |
Determines if scroll bars appear when a form exceeds the window size |
|
AutoScrollMargin |
Enables/disables the margin around a control when scrolling |
|
AutoScrollMinSize |
Minimum size for the autoscroll region |
|
AutoSize |
Determines if labels or picture controls are resized to fit the contents |
|
BackColor |
Sets the background color of a form |
|
BackgroundImages |
Sets the background image of a form |
|
BorderStyle |
Controls the border of a form |
|
CancelButton |
Sets the control as the Cancel button for the form, which makes it the same as pressing the Esc key |
|
CheckAlign |
Sets the location of a Check Box control within another control |
|
Checked |
Indicates if a control is checked |
|
ContextMenu |
Determines the shortcut menu displayed when a user right-clicks a control |
|
ControlBox |
Sets the Control/System Menu for a form |
|
Cursor |
Sets the cursor when the mouse pointer is over a control |
|
DrawGrid |
Determines if the drawing grid is displayed on a form |
|
Enabled |
Determines if a control is enabled on a form |
|
FlatStyle |
Determines how a control is displayed when a user moves the mouse over a control; the three settings are flat, pop-up, and standard |
|
Font |
Sets the font used in the control |
|
ForeColor |
Determines the foreground color when displaying text and graphics on a control |
|
HelpButton |
Displays a Help button on a form's caption bar |
|
Icon |
Sets the icon on a form when a form is minimized |
|
Image |
Sets the image displayed on the face of a control for radio buttons, buttons, check boxes, or picture boxes |
|
ImageAlign |
Sets the alignment of an image on the face of a control |
|
ImageIndex |
Index value of an image when it is displayed on the face of a control |
|
ImageList |
List used to select an image to display on a control's face |
|
Interval |
Sets the number of milliseconds in a timer's countdown; zero disables the timer |
|
Items |
Sets or returns the list of items in a combo, list, directory, drive, or file list |
|
Large / Small Change |
Used by scroll bars to determine the change when a user clicks a control |
|
Location |
Sets the X and Y values of a control |
|
Locked |
Prevents a control from being moved or resized |
|
Maximize / Minimize Box |
Determines if a Maximize or Minimize box is displayed |
|
Maximum / Minimum |
Used by horizontal/vertical scroll bars to determine a bar's maximum or minimum value |
|
MultiLine |
Read-only property that determines if a text box can hold more than one line |
|
Opacity |
Sets a form to be opaque (100) or transparent (0) |
|
RightToLeft |
Sets the direction of writing text in a text box |
|
Scrollbars |
Determines if a text box has horizontal/vertical scroll bars |
|
Size |
Sets the size of a control in pixels |
|
Sorted |
Used by combo and list boxes to set if the data is sorted |
|
StartPosition |
Sets the control's position on a form when it first appears |
|
TabIndex |
Sets the control's position in the tab order of the parent form |
|
TabStop |
Determines if the control is included in tabbing stops |
|
Text |
Sets the value/text of a control |
|
TextAlign |
Sets the alignment of text within a control |
|
Visible |
Sets the visibility of a control (true or false) |
|
WindowState |
Returns the state of a form: Minimized or Maximized |
|
Event |
Description |
|---|---|
|
Activate |
Triggered when a form is controlled |
|
ButtonClick |
Triggered by clicking a toolbar button |
|
ButtonDropDown |
Triggered by clicking a drop-down button style |
|
CheckStateChanged |
Triggered when a control's checked state has changed |
|
CheckedChanged |
Triggered by changing a control's Checked property |
|
Click |
Triggered by a mouse click |
|
Closed |
Triggered when a form control is closed |
|
CloseUp |
Triggered by the Date/Time Picker control when a date is selected |
|
Closing |
Triggered during the process of closing a form |
|
DateChanged |
Triggered by the Calendar control when the range of dates changes |
|
DateSelected |
Triggered by the Calendar control when a date or range of dates is selected |
|
Deactivated |
Triggered when a form is deactivated |
|
DoubleClick |
Triggered by a double-click of the mouse on a control |
|
DragDrop |
Triggered by dragging and dropping a control on a form |
|
DragEnter |
Triggered by dragging a control into a control's client area |
|
DragLeave |
Triggered when the mouse drags an item outside a client control area |
|
DragOver |
Triggered when a drag-and-drop operation is in progress and an item is over a client area of a control |
|
DrawItem |
Triggered when a panel on a status bar needs to be repainted |
|
Enter |
Triggered when a control becomes the active control |
|
Format |
Triggered when a control wants text to be displayed in a callback field |
|
FormatQuery |
Triggered by a control querying how to draw or paint a custom string |
|
GiveFeedback |
Triggered when a mouse drags an item |
|
Help |
Triggered by a user requesting help for a control |
|
InputLangChange |
Triggered when the input language of a form is changed |
|
InputLangChangedRequest |
Triggered when the system changes the input language |
|
KeyDown |
Triggered when a key is first pressed |
|
KeyPress |
Triggered when a key is first released |
|
KeyUp |
Triggered when a key is released |
|
Layout |
Triggered when a control first lays out its contents |
|
Leave |
Triggered when a control is no longer active |
|
MDIChildActivate |
Triggered when an MDI child window is activated |
|
MenuComplete |
Triggered when menu selection is finished |
|
MenuStart |
Triggered when a menu is started |
|
MouseDown |
Triggered when a mouse button is clicked |
|
MouseEnter |
Triggered when the mouse first moves into a control's client area |
|
MouseHover |
Triggered when a mouse remains in a control's client area |
|
MouseLeave |
Triggered when the mouse leaves a client control |
|
MouseMove |
Triggered by mouse movement |
|
MouseUp |
Triggered by releasing a mouse button |
|
Move |
Triggered when a control is moved |
|
PanelClick |
Triggered by clicking a panel in a status bar |
|
QueryContinueDrag |
Triggered by dragging a control with the mouse |
|
Resize |
Triggered when a control is resized |
|
Scroll |
Triggered by moving a scroll bar's thumb |
|
TextChanged |
Triggered when the Text property is changed |
|
UserString |
Triggered when a control wants to parse a string |
|
Validated |
Triggered when a control is validated |
|
Validating |
Triggered when a control is being validated |
|
ValueChange |
Triggered when the value of a control is changed |