Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

QueryContinueDragEventArgs::Action Property

 

Gets or sets the status of a drag-and-drop operation.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
property DragAction Action {
	DragAction get();
	void set(DragAction value);
}

Property Value

Type: System.Windows.Forms::DragAction

A DragAction value.

By default, the QueryContinueDrag event sets Action to DragAction::Cancel if the ESC key was pressed and sets Action to DragAction::Drop if the left, middle, or right mouse button is pressed.

This code excerpt demonstrates using the QueryContinueDragEventArgs class with the QueryContinueDrag event. See the DoDragDrop method for the complete code example.

void ListDragSource_QueryContinueDrag( Object^ sender, System::Windows::Forms::QueryContinueDragEventArgs^ e )
{
   // Cancel the drag if the mouse moves off the form.
   ListBox^ lb = dynamic_cast<ListBox^>(sender);
   if ( lb != nullptr )
   {
      Form^ f = lb->FindForm();

      // Cancel the drag if the mouse moves off the form. The screenOffset
      // takes into account any desktop bands that may be at the top or left
      // side of the screen.
      if ( ((Control::MousePosition.X - screenOffset.X) < f->DesktopBounds.Left) || ((Control::MousePosition.X - screenOffset.X) > f->DesktopBounds.Right) || ((Control::MousePosition.Y - screenOffset.Y) < f->DesktopBounds.Top) || ((Control::MousePosition.Y - screenOffset.Y) > f->DesktopBounds.Bottom) )
      {
         e->Action = DragAction::Cancel;
      }
   }
}

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft