See Also Example
Applies To
Check box, combo box
Description
Determines manual or automatic dragging mode for a drag-and-drop operation
Usage
[form.]control.DragMode[ = mode ]
Setting
The DragMode property settings are:
Setting Description
0 (Default) Manual; requires using the Drag method to initiate dragging on the source control.
1 Automatic; clicking the source control automatically initiates dragging.
Remarks
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 MouseDown event prior to dragging.
Clicking while the mouse pointer is over a target control or form during a drag operation generates a DragDrop This ends the drag operation. Dragging may also generate a DragOver event.
Note While a control is being dragged, it cannot recognize other user-initiated mouse or keyboard events (KeyDown , KeyPress or KeyUp , MouseDown, MouseMove , or MouseUp ). However, the control can receive events initiated by code or by a DDE link.
Data Type
Integer (Enumerated)
Help:
DragDrop Event
DragIcon Property
DragOver Event
Programmer's Guide:
Chapter 12, "Responding to Mouse Events"
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.
Else
Command1.DragMode = 0 ' Or turn if off.
End If
End Sub