DblClick Event

See Also3WZAIAL              Example3MT7YTQ>Low

Applies To

Form14TJ2LN (not MDI form), combo box1YZXFF6, file list box1M6S8UX, frame1KX6ZP8, grid2VGT0PT, image9A4FCA, label3MNIZ8D, list boxG11UCK, OLE control2HQDVVU, option buttonJYBO08, picture box31MYIWX, text boxYPYZDG.

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 Style1L09GO8 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 array8G7Y0UU.  You can use a DblClick event procedure for an "implied action" such as double-clicking an icon529QBG 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 Default31OHP7N property set to True.  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: MouseDownD0VNMJ, Click68UQAKP, MouseUpD0VNMJ, 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 Panel56C790N.  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.

 


See Also

Help

Click Event68UQAKP

MouseDown, MouseUp EventsD0VNMJ

 

Programmer's Guide:

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.

   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