CommandButton Control

The CommandButton control is used to begin, interrupt, or end a process. When clicked, it invokes a command that has been written into its Click event procedure.

Most applications have command buttons that allow the user to simply click them to perform actions. When the user chooses the button, it not only carries out the appropriate action, it also looks as if it's being pushed in and released and is therefore sometimes referred to as a push button.

Syntax

CommandButton

The CommandButton control has the following properties, methods, and events.

Properties Methods Events
Appearance Move Click
BackColor, ForeColor Refresh GotFocus
Cancel SetFocus KeyDown, KeyUp
Caption ZOrder KeyPress
Container LostFocus
Default MouseDown, MouseUp
Enabled MouseMove
Font
FontBold
FontItalic
FontStrikethru
FontUnderline
FontName
FontSize
Height, Width
HWnd
Left, Top
Name
Parent
Style
TabIndex
TabStop
Tag
Value
Visible

Remarks

To display text on a CommandButton control, set its Caption property. A user can always choose a CommandButton by clicking it. To allow the user to choose it by pressing ENTER, set the Default property to True. To allow the user to choose the button by pressing ESC, set the Cancel property of the CommandButton to True.