Action Property
Collapse the table of content
Expand the table of content

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:
© 2016 Microsoft