DragMode Property

See Also13UKA5A                 Example1F1HQZC>Low

Applies To

Check box9P3BU5, combo box1YZXFF6, command buttonXJSPC0, data control2E1FEX3, directory list boxO9U5A0, drive list box5WJO0PW, file list box1M6S8UX, frame1KX6ZP8, grid2VGT0PT, horizontal scroll bar1JSJOS7, image9A4FCA, label3MNIZ8D, list boxG11UCK, OLE control2HQDVVU, option buttonJYBO08, picture box31MYIWX, text boxYPYZDG, vertical scroll bar1JSJOS7.


Determines manual or automatic dragging mode for a drag-and-drop operation1MXLXNZ.


[form.]control.DragMode[ = mode ]


The DragMode property settings are:

Setting   Description


  0          (Default) Manual; requires using the Drag2IEV8PA method to initiate dragging on the source control.

  1          Automatic; clicking the source control automatically initiates dragging.



When DragMode is set to 1 (Automatic), the control does not respond as usual to mouse input messages.  Use the 0 (Manual) setting to determine when dragging begins or ends; this is useful for initiating dragging in response to a keyboard or menu command, or for allowing a source control to recognize a MouseDownD0VNMJ event prior to dragging.

Clicking while the mouse pointer is over a target control or form during a drag operation generates a DragDrop1EBOJGL event for the target object.  This ends the drag operation.  Dragging may also generate a DragOver2TUGMAC event.


Note   While a control is being dragged, it cannot recognize other user-initiated mouse or keyboard events (KeyDownRI06O6, KeyPressPFFDUA or KeyUpRI06O6, MouseDown, MouseMove1D70SW5, or MouseUpD0VNMJ).  However, the control can receive events initiated by code or by a DDEDEFDDE link.


Data Type

IntegerDOKXHY (Enumerated)

See Also


DragDrop Event1EBOJGL

DragIcon Property3G3M07O

DragOver Event2TUGMAC


Programmer's Guide:

Chapter 12, "Responding to Mouse Events"

DragMode Property Example

This example enables and disables the ability to drag a command button each time a form is clicked.  To try this example, paste the code into the Declarations section of a form that contains a command button.  Then press F5 and click the form.

Sub Form_Click ()

  If Command1.DragMode = 0 Then    ' Check DragMode.
    Command1.DragMode = 1          ' Turn it on.
    Command1.DragMode = 0          ' Or turn if off.
  End If
End Sub