ItemDragEventArgs ItemDragEventArgs ItemDragEventArgs ItemDragEventArgs Class

定义

提供数据ItemDrag的事件ListViewTreeView控件。Provides data for the ItemDrag event of the ListView and TreeView controls.

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

示例

下面的示例演示如何使用ItemDragEventArgs启用中的拖放操作时TreeViewThe following example illustrates the use of ItemDragEventArgs when enabling drag-and-drop operations within a TreeView. Button属性确定是否应移动或复制到其目标被拖动的节点。The Button property determines whether the dragged node should be moved or copied to its destination. 表示的节点Item属性,然后传递给TreeView控件的DoDragDrop方法以及一个值,该值所需的效果。The node, represented by the Item property, is then passed to the TreeView control's DoDragDrop method along with a value indicating the desired effect.

有关完整示例,请参阅TreeView.ItemDrag参考主题。For the complete example, see the TreeView.ItemDrag reference topic.

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 'treeView1_ItemDrag

注解

ItemDrag用户开始拖动项时发生事件。The ItemDrag event occurs when the user begins dragging an item. ItemDragEventArgs对象指定哪个鼠标按钮曾按下。An ItemDragEventArgs object specifies which mouse button was pressed.

构造函数

ItemDragEventArgs(MouseButtons) ItemDragEventArgs(MouseButtons) ItemDragEventArgs(MouseButtons) ItemDragEventArgs(MouseButtons)

初始化的新实例ItemDragEventArgs类与指定的鼠标按钮。Initializes a new instance of the ItemDragEventArgs class with a specified mouse button.

ItemDragEventArgs(MouseButtons, Object) ItemDragEventArgs(MouseButtons, Object) ItemDragEventArgs(MouseButtons, Object) ItemDragEventArgs(MouseButtons, Object)

初始化的新实例ItemDragEventArgs类与指定的鼠标按钮和正被拖动的项。Initializes a new instance of the ItemDragEventArgs class with a specified mouse button and the item that is being dragged.

属性

Button Button Button Button

获取一个值,该值指示在拖动操作期间按下的鼠标按钮。Gets a value that indicates which mouse buttons were pressed during the drag operation.

Item Item Item Item

获取正被拖动的项。Gets the item that is being dragged.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于