See Also Example
Check box, combo box, command button , data control , directory list box , drive list box , file list box , frame , grid , horizontal scroll bar , image , label , list box , OLE control , option button , picture box , text box , vertical scroll bar .
Determines manual or automatic dragging mode for a drag-and-drop operation.
[form.]control.DragMode[ = mode ]
The DragMode property settings are:
0 (Default) Manual; requires using the Drag 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 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. event for the target object.
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.
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.