When you design Visual Basic applications, you often drag controls around on the form. The drag-and-drop features in Visual Basic allow you to extend this ability to the user at run time. The action of holding a mouse button down and moving a control is called dragging, and the action of releasing the button is called dropping.
Note Dragging a control at run time doesn't automatically change its location — you must program the relocation yourself, as described in "Changing the Position of a Control." Often, dragging is used only to indicate that some action should be performed; the control retains its original position after the user releases the mouse button.
Using the following drag-and-drop properties, events, and method, you can specify both the meaning of a drag operation and how dragging can be initiated (if at all) for a given control.
Category | Item | Description |
Properties | DragMode | Enables automatic or manual dragging of a control. |
DragIcon | Specifies what icon is displayed when the control is dragged. | |
Events | DragDrop | Recognizes when a control is dropped onto the object. |
DragOver | Recognizes when a control is dragged over the object. | |
Methods | Drag | Starts or stops manual dragging. |
All controls except menus, timers, lines, and shapes support the DragMode and DragIcon properties and the Drag method. Forms recognize the DragDrop and DragOver events, but they don't support the DragMode and DragIcon properties or the Drag method.
Note Controls can only be dragged when they do not have the focus. To prevent a control from getting the focus, set its TabStop property to False.