CancelButton Property
Applies To
Form
Description
Gets or sets the button on the form that is clicked when the user presses the ESC key.
Usage
GGet Form.CancelButton, var
GSet Form.CancelButton, value
- Form
- Name of a form or string variable containing a form name.
- var
- String variable that will contain the value of the property.
- value
- String expression for the new value of the property.
Values
The name of any button on the form.
Default: None
Remarks
The cancel button for a form is the button control that is clicked whenever the user presses the ESC key. The button assigned to this property must be a button that is on the current form or located within a container on the current form.
This property allows you to designate a default action to occur when the user presses the ESC key in your application. You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ESC key to close a window without committing changes instead of manually clicking the cancel button with their mouse.
CancelButton may not work if another control on the form intercepts the ESC key. For example, if you have a ComboBox open on your form, ESC will close the ComboBox instead of closing the Form.
The Button control assigned to CancelButton must be visible on the form, or else pressing the ESC key will have no effect.
See Also
Form, Button, AcceptButton
Example
GSet frmMain.CancelButton, "btnCancel"