DblClick

Occurs when the user presses and releases a mouse button, then presses and releases it again over an object.

For a form, the DblClick event occurs when the user double-clicks a disabled control or a blank area of a form. For a control, it occurs when the user:

Syntax

Private Sub object_DblClick (index)

Part Description
object An object expression that evaluates to an object.
index Identifies the control.

Remarks

You can use a DblClick event procedure for an implied action, such as double-clicking an icon to open a window or document. You can also use this type of procedure to carry out multiple steps with a single action, such as double-clicking to select an item in a list box and to close the dialog box.

To produce such shortcut effects in Visual Basic, use a DblClick event procedure for a list box or file list box in tandem with a default button — a CommandButton control with its Default property set to True. As part of the DblClick event procedure for the list box, you simply call the default button's Click event.

For those objects that receive Mouse events, the events occur in this order:

If DblClick does not occur within the system's double-click time limit, the object recognizes another Click event. The double-click time limit may vary because the user can set the double-click speed in the Control Panel. When you are attaching procedures for these related events, be sure that their actions do not conflict. Controls that do not receive DblClick events may receive two clicks instead of a DblClick.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

If there is code in the Click event, the DblClick event will never trigger.