Visual Basic Reference

Visual Studio 6.0

Drag Method

See Also    Example    Applies To

Begins, ends, or cancels a drag operation of any control except the Line, Menu, Shape, Timer, or CommonDialog controls. Doesn't support named arguments.

Syntax

object.Drag action

The Drag method syntax has these parts:

Part Description
object Required. An object expression that evaluates to an object in the Applies To list. If object is omitted, the object whose event procedure contains the Drag method is assumed.
action Optional. A constant or value that specifies the action to perform, as described in Settings. If action is omitted, the default is to begin dragging the object.

Settings

The settings for action are:

Constant Value Description
vbCancel 0 Cancels drag operation
vbBeginDrag 1 Begins dragging object
vbEndDrag 2 Ends dragging and drop object

Remarks

These constants are listed in the Visual Basic (VB) object library in the Object Browser.

Using the Drag method to control a drag-and-drop operation is required only when the DragMode property of the object is set to Manual (0). However, you can use Drag on an object whose DragMode property is set to Automatic (1 or vbAutomatic).

If you want the mouse pointer to change shape while the object is being dragged, use either the DragIcon or MousePointer property. The MousePointer property is only used if no DragIcon is specified.

The Drag method generally acts synchronously, meaning that subsequent statements aren't executed until the drag action is complete. It can, however, act asynchronously if the DragMode property for the control is set to Manual (0 or vbManual).

Show: