语言

ItemDragEventArgs 类

定义

为事件ItemDrag和ListView控件提供数据TreeView。

public ref class ItemDragEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class ItemDragEventArgs : EventArgs
public class ItemDragEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type ItemDragEventArgs = class
    inherit EventArgs
type ItemDragEventArgs = class
    inherit EventArgs
Public Class ItemDragEventArgs
Inherits EventArgs
继承
ItemDragEventArgs
特性

示例

下面的示例演示了在一个ItemDragEventArgs中启用拖放操作时使用的用法TreeView。 该 Button 属性确定拖动的节点是应移动还是复制到其目标。 然后,由属性表示Item的TreeView节点将传递给DoDragDrop控件的方法以及指示所需效果的值。

有关完整示例,请参阅 TreeView.ItemDrag 参考主题。

private:
   void treeView1_ItemDrag( Object^ /*sender*/, ItemDragEventArgs^ e )
   {
      
      // Move the dragged node when the left mouse button is used.
      if ( e->Button == ::MouseButtons::Left )
      {
         DoDragDrop( e->Item, DragDropEffects::Move );
      }
      // Copy the dragged node when the right mouse button is used.
      else
      
      // Copy the dragged node when the right mouse button is used.
      if ( e->Button == ::MouseButtons::Right )
      {
         DoDragDrop( e->Item, DragDropEffects::Copy );
      }
   }
private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
{
    // Move the dragged node when the left mouse button is used.
    if (e.Button == MouseButtons.Left)
    {
        DoDragDrop(e.Item, DragDropEffects.Move);
    }

    // Copy the dragged node when the right mouse button is used.
    else if (e.Button == MouseButtons.Right)
    {
        DoDragDrop(e.Item, DragDropEffects.Copy);
    }
}
Private Sub treeView1_ItemDrag(ByVal sender As Object, ByVal e As ItemDragEventArgs)

    ' Move the dragged node when the left mouse button is used.
    If e.Button = MouseButtons.Left Then
        DoDragDrop(e.Item, DragDropEffects.Move)

    ' Copy the dragged node when the right mouse button is used.
    ElseIf e.Button = MouseButtons.Right Then
        DoDragDrop(e.Item, DragDropEffects.Copy)
    End If
End Sub

注解

当用户 ItemDrag 开始拖动项时发生该事件。 对象 ItemDragEventArgs 指定按下了哪个鼠标按钮。

构造函数

名称 说明
ItemDragEventArgs(MouseButtons, Object)

使用指定的鼠标按钮和正在拖动的项初始化类的新实例 ItemDragEventArgs 。

ItemDragEventArgs(MouseButtons)

使用指定的鼠标按钮初始化类的新实例 ItemDragEventArgs 。

属性

名称 说明
Button

获取一个值,该值指示拖动操作期间按下了哪些鼠标按钮。

Item

获取正在拖动的项。

方法

名称 说明
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type。

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于