This class encapsulates the event arguments for the Control.DragEnter , Control.DragDrop , and Control.DragOver events. When you start a drag-drop operation using Control.DoDragDrop() , you can specify the DragDropEffects that the drag source can support. Then, as the drag-drop action proceeds, controls receive DragEnter , DragDrop , and DragOver events, which have DragEventArgs . You can retrieve the AllowedEffect property to determine what the source will permit, and then set the Effect property to specify which you can support as a target. It will also raise GiveFeedback events, which allow you to determine the current Effect , perhaps changing the Control object's appearance or cursors . You might base this on the KeyState . Sadly, the KeyState has not been well encapsulated, and you have to mess around with magic numbers in a bitfield :
You can also retrieve the actual Data that is being dragged, through the IDataObject that encapsulates it. public class DragEventArgs : EventArgs { // Public Constructors public DragEventArgs (IDataObject data , int keyState , int x , int y , DragDropEffects allowedEffect , DragDropEffects effect ); // Public Instance Properties public DragDropEffects AllowedEffect {get; } public IDataObject Data {get; } public DragDropEffects Effect {set; get; } public int KeyState {get; } public int X {get; } public int Y {get; } } HierarchySystem.Object System.EventArgs DragEventArgs Passed ToControl.RaiseDragEvent() , System.Windows.Forms.Design.ComponentTray.{OnDragDrop() , OnDragEnter() , OnDragOver()} , System.Windows.Forms.Design.ControlDesigner.{OnDragDrop() , OnDragEnter() , OnDragOver()} , DragEventHandler.{BeginInvoke() , Invoke()} |