See Also Example
Form (not MDI form), combo box, file list box , frame , grid , image , label , list box , OLE control , option button , picture box , text box .
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.
Sub Form_DblClick ( )
Sub ctlname_DblClick (Index As Integer)
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. property set to True.
For those objects that receive mouse events, the events occur in this order: MouseDown, Click , MouseUp , and DblClick.
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.
MouseDown, MouseUp Events
Chapter 12, "Responding to Mouse Events"
DblClick Event Example
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.
Sub List1_DblClick ()
Command1.Value = True ' Trigger Click event.
Sub Command1_Click ()
Text1.Text = List1.Text ' Display selection.