Occurs during a drag-and-drop operation and enables the drag source to determine whether the drag-and-drop operation should be canceled.
The Control.QueryContinueDrag event is raised when there is a change in the keyboard or mouse button state during a drag-and-drop operation. The Control.QueryContinueDrag event enables the drag source to determine whether the drag-and-drop operation should be canceled.
The following describes how and when events related to drag-and-drop operations are raised.
The Control.DoDragDrop(object, DragDropEffects) method determines the control under the current cursor location. It then checks to see if the control is a valid drop target.
If the control is a valid drop target, the Control.GiveFeedback event is raised with the drag-and-drop effect specified. For a list of drag-and-drop effects, see the System.Windows.Forms.DragDropEffects enumeration.
Changes in the mouse cursor position, keyboard state, and mouse button state are tracked.
If the user moves out of a window, the Control.DragLeave event is raised.
If the mouse enters another control, the Control.DragEnter for that control is raised.
If the mouse moves but stays within the same control, the Control.DragOver event is raised.
If there is a change in the keyboard or mouse button state, the Control.QueryContinueDrag event is raised and determines whether to continue the drag, to drop the data, or to cancel the operation based on the value of the QueryContinueDragEventArgs.Action property of the event's System.Windows.Forms.QueryContinueDragEventArgs.
If the value of System.Windows.Forms.DragAction is Continue, the Control.DragOver event is raised to continue the operation and the Control.GiveFeedback event is raised with the new effect so appropriate visual feedback can be set. For a list of valid drop effects, see the System.Windows.Forms.DragDropEffects enumeration.
If the value of System.Windows.Forms.DragAction is Drop, the drop effect value is returned to the source, so the source application can perform the appropriate operation on the source data; for example, cut the data if the operation was a move.
If the value of System.Windows.Forms.DragAction is Cancel, the Control.DragLeave event is raised.
By default, the Control.QueryContinueDrag event sets QueryContinueDragEventArgs.Action to Cancel in System.Windows.Forms.DragAction if the ESC key was pressed and sets QueryContinueDragEventArgs.Action to Drop in System.Windows.Forms.DragAction if the left, middle, or right mouse button is pressed.
For more information about handling events, see Consuming Events.