DragEventArgs

DragEventArgs

System. Windows .Forms (system. windows .forms.dll) class

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 :


1

The left mouse button


2

The right mouse button


4

The Shift key


8

The Control key


16

The middle mouse button


32

The Alt key

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; } } 

Hierarchy

System.Object System.EventArgs DragEventArgs

Passed To

Control.RaiseDragEvent() , System.Windows.Forms.Design.ComponentTray.{OnDragDrop() , OnDragEnter() , OnDragOver()} , System.Windows.Forms.Design.ControlDesigner.{OnDragDrop() , OnDragEnter() , OnDragOver()} , DragEventHandler.{BeginInvoke() , Invoke()}



. Net Windows Forms in a Nutshell
.NET Windows Forms in a Nutshell
ISBN: 0596003382
EAN: 2147483647
Year: 2002
Pages: 794

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net