ItemDragEventArgs ItemDragEventArgs ItemDragEventArgs ItemDragEventArgs Class

定义

ItemDragListView 控件的 TreeView 事件提供数据。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 TreeView中启用拖放操作时的用法。The 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

注解

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)

适用于