See Also Example
Applies To
Form (not MDI form), combo box
Description
Occurs when the user presses and releases a mouse button and then presses and released 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:
Double-clicks a control with the left mouse button.
Double-clicks an item in a combo box whose Style property = 1 (Simple); in a file list box; or in a list box.
Syntax
Sub Form_DblClick ( )
Sub ctlname_DblClick (Index As Integer)
Remarks
The argument Index uniquely identifies a control if it is in a control array You can use a DblClick event procedure for an "implied action" such as double-clicking an icon to open a window or document. This type of procedure is also useful for carrying 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, you can use a DblClick procedure for a list box or file list box in tandem with a default buttona command button with its Default As part of the DblClick procedure for the list box, you simply call the default button's Click procedure.
For those objects that receive mouse events, the events occur in this order: MouseDown
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 with the Control Panel . When you are attaching procedures for these related events, be sure that their actions don't conflict. Controls that do not receive DblClick events may receive two clicks instead of a DblClick.
Note To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.
Help
Click Event
MouseDown, MouseUp Events
Programmer's Guide:
Chapter 12, "Responding to Mouse Events"
The example displays a selected list item in a text box when either a command button is clicked or a list item is double-clicked. To try this example, paste the code into the Declarations section of a form that contains list box, a text box and a command button. Then press F5 and click the command button or double click a list box item.
Sub Form_Load ()
List1.AddItem "John" ' Add list box entries.
List1.AddItem "Paul"
List1.AddItem "George"
List1.AddItem "Ringo"
End Sub
Sub List1_DblClick ()
Command1.Value = True ' Trigger Click event.
End Sub
Sub Command1_Click ()
Text1.Text = List1.Text ' Display selection.
End Sub