ItemDragEventArgs 類別

定義

提供 ItemDragListView 控制項的 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
屬性

範例

下列範例說明在 內 TreeView 啟用拖放作業時所使用的 ItemDragEventArgs 。 屬性 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)

使用指定的滑鼠鍵來初始化 ItemDragEventArgs 類別的新執行個體。

ItemDragEventArgs(MouseButtons, Object)

用指定的滑鼠鍵和被拖曳的項目來初始化 ItemDragEventArgs 類別的新執行個體。

屬性

Button

取得值,表示在拖曳作業時按下哪個滑鼠按鈕。

Item

取得被拖曳的項目。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於