Visual Basic Reference

Default Property

Returns or sets a value that determines which CommandButton control is the default command button on a form.

Syntax

object.Default [= boolean]

The Default property syntax has these parts:

Part

Description

Object

An object expression that evaluates to an object in the Applies To list.

Boolean

A Boolean expression that specifies whether the command button is the default, as described in Settings.

Settings

The settings for boolean are:

Setting

Description

True

The CommandButton is the default command button.

False

(Default) The CommandButton isn't the default command button.

Remarks

Only one command button on a form can be the default command button. When Default is set to True for one command button, it's automatically set to False for all other command buttons on the form. When the command button's Default property setting is True and its parent form is active, the user can choose the command button (invoking its Click event) by pressing ENTER. Any other control with the focus doesn't receive a keyboard event (KeyDown, KeyPress, or KeyUp) for the ENTER key unless the user has moved the focus to another command button on the same form. In this case, pressing ENTER chooses the command button that has the focus instead of the default command button.

For a form or dialog box that supports an irreversible action such as a delete operation, make the Cancel button the default command button by setting its Default property to True.

For OLE container controls, the Default property is provided only for those objects that specifically behave like CommandButton controls.

Show:
Inherited
Protected

Was this page helpful?

Your feedback about this content is important.Let us know what you think.