ItemDragEventArgs.Item プロパティ

定義

ドラッグされている項目を取得します。

public:
 property System::Object ^ Item { System::Object ^ get(); };
public object Item { get; }
public object? Item { get; }
member this.Item : obj
Public ReadOnly Property Item As Object

プロパティ値

ドラッグされている項目を表すオブジェクト。

次の例は、コントロール内でドラッグ アンド ドロップ操作を有効にする場合の ItemDragEventArgs の使用方法を TreeView 示しています。 プロパティは Button 、ドラッグしたノードを移動先に移動するかコピーするかを決定します。 プロパティでItem表されるノードは、ドラッグ アンド ドロップ操作の目的のDoDragDrop効果を示す値と共にコントロールの メソッドに渡されますTreeView

完全な例については、リファレンス トピックを 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

注釈

このプロパティを使用して、 コントロールまたは ListView コントロールからTreeViewドラッグする項目を決定できます。

適用対象