• Source Control Events: These events occur when a mouse pointer triggers some action on a source control. The following are the source control events:

    . To get a glimpse of these PrepKits, you can download its free demo version (which contains 15 free practice questions) from:

    Download link: https://www.ucertify.com/exams/Microsoft/70-526-VB.html

    1. MouseDown Event: It occurs when the mouse button is pressed and the mouse pointer is over the source control. A method that handles this event calls the DoDragDrop method of the source control.
    2. GiveFeedback Event: It occurs when a drag-and-drop operation is initiated. The appearance of the mouse pointer can be modified by the source of a drag event. In this event, a user can obtain the visual feedback during the operation. This event provides a custom mouse pointer to a user.
    3. QueryContinueDrag Event: It occurs during a drag-and-drop operation. It is raised when the keyboard or the mouse button state changes during the operation. It also enables the drag source in order to determine whether the drag-and-drop operation is cancelled.
  • Target Control Events: These events occur when a mouse pointer triggers some action on a target control. The following are the source control events:
    1. DragEnter Event: It occurs when an object is dragged into the bounds of the target control. It is raised when the mouse cursor is first dragged over the target control during a drag-and-drop operation.
    2. DragOver Event: It occurs when an object is dragged over the bounds of the target control. It is raised when the mouse cursor is within the bounds of the control.
    3. DragDrop Event: It occurs when the mouse button is released over the target control and a drag-and-drop operation is completed.
    4. DragLeave Event: It occurs when the an object is dragged out of the bounds of the target control. It occurs when the current drag-and-drop operation is cancelled.

Sequence of a Drag-and-Drop Operation

  1. The drag-and-drop operation is initiated by calling the DoDragDrop method within the MouseDown event handler on the source control. The method contains two parameters, namely the Object data that specifies the desired data to pass and the DragDropEffects data value that specifies a particular drag operation on a control. The method determines under which control the current mouse cursor is located. It then checks whether the valid drop target operation has been performed. In this sequence, a new DataObject object is automatically created.
  2. The GiveFeedback event is raised when a custom mouse pointer is displayed during the dragging operation. The QueryContinueDrag event is raised to determine whether the drag operation should be continued or aborted.
  3. The drop-and-drop operation is allowed when the AllowDrop property is set to true in the Properties window at design time. The property can be set to true programmatically in the Form_Load event of a Windows form.
  4. The DragEnter event for a target control is raised when the mouse cursor is first dragged over the control. The DragOver event takes place when a mouse pointer stays over the bounds of a control.
  5. Finally, the DragDrop event is raised when the mouse button is released over a valid target control. In the Windows form, the event handler extracts the appropriate data from the DataObject object. Data is then displayed in the target control.

DragDropEffects Enumeration ValuesFlagsAttributeDragEventArgsGiveFeedbackEventArgsControl

Member Values Description
All During a drag-and-drop operation data is copied, dragged, and removed from the source control. The data is then scrolled and dropped onto the target control.
Copy During a drag operation, data is copied to the target control.
Link During the operation, data from the source control is linked to the target control.
Move During the operation, data is moved from the source control to the target control.
None During a drag-and-drop operation, the target control does not accept the data from the source control.
Scroll During a drag-and-drop operation, the scrolling operation is initiated or is currently being performed.

Implementing Drag-and-Drop Operations between Applications

  • A target control should allow one of the drag effects being specified when the DoDragDrop method is called.
  • A target control should accept data in the same format that was set when the DoDragDrop method is called.

Implementing Drag-and-Drop Operations by using a TreeView ControlItemDragItemDragEventArgs https://www.ucertify.com/exams/Microsoft/70-526-VB.html