ItemDragEventArgsとは? わかりやすく解説

ItemDragEventArgs クラス

ListView コントロールと TreeView コントロールの ItemDrag イベントのデータを提供します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Class ItemDragEventArgs
    Inherits EventArgs
Dim instance As ItemDragEventArgs
[ComVisibleAttribute(true)] 
public class ItemDragEventArgs : EventArgs
[ComVisibleAttribute(true)] 
public ref class ItemDragEventArgs : public
 EventArgs
/** @attribute ComVisibleAttribute(true) */ 
public class ItemDragEventArgs extends EventArgs
ComVisibleAttribute(true) 
public class ItemDragEventArgs extends
 EventArgs
解説解説

ItemDrag イベントは、ユーザーが項目のドラッグを開始すると発生します。ItemDragEventArgs オブジェクトは、どちらのマウス ボタンが押されたかを示します。

使用例使用例

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

詳細については、TreeView.ItemDrag のリファレンス トピックを参照してください。

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
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:
   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.get_Button().Equals(get_MouseButtons().Left)) {
        DoDragDrop(e.get_Item(), DragDropEffects.Move);
    }
    // Copy the dragged node when the right mouse button is used.
    else {
        if (e.get_Button().Equals(get_MouseButtons().Right)) {
            DoDragDrop(e.get_Item(), DragDropEffects.Copy);
        }
    }
} //treeView1_ItemDrag
継承階層継承階層
System.Object
   System.EventArgs
    System.Windows.Forms.ItemDragEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ItemDragEventArgs コンストラクタ (MouseButtons)

マウス ボタンを指定して、ItemDragEventArgs クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    button As MouseButtons _
)
Dim button As MouseButtons

Dim instance As New ItemDragEventArgs(button)
public ItemDragEventArgs (
    MouseButtons button
)
public:
ItemDragEventArgs (
    MouseButtons button
)
public ItemDragEventArgs (
    MouseButtons button
)
public function ItemDragEventArgs (
    button : MouseButtons
)

パラメータ

button

押されたマウス ボタンを示す MouseButtons 値のビットごとの組み合わせ。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ItemDragEventArgs コンストラクタ (MouseButtons, Object)

マウス ボタン、およびドラッグされている項目を指定して、ItemDragEventArgs クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    button As MouseButtons, _
    item As Object _
)
Dim button As MouseButtons
Dim item As Object

Dim instance As New ItemDragEventArgs(button,
 item)
public ItemDragEventArgs (
    MouseButtons button,
    Object item
)
public:
ItemDragEventArgs (
    MouseButtons button, 
    Object^ item
)
public ItemDragEventArgs (
    MouseButtons button, 
    Object item
)
public function ItemDragEventArgs (
    button : MouseButtons, 
    item : Object
)

パラメータ

button

押されたマウス ボタンを示す MouseButtons 値のビットごとの組み合わせ。

item

ドラッグされている項目。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ItemDragEventArgs コンストラクタ

ItemDragEventArgs クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
ItemDragEventArgs (MouseButtons) マウス ボタンを指定して、ItemDragEventArgs クラスの新しいインスタンスを初期化します。
ItemDragEventArgs (MouseButtons, Object) マウス ボタン、およびドラッグされている項目を指定して、ItemDragEventArgs クラスの新しいインスタンスを初期化します。
参照参照

関連項目

ItemDragEventArgs クラス
ItemDragEventArgs メンバ
System.Windows.Forms 名前空間

ItemDragEventArgs プロパティ


ItemDragEventArgs メソッド


ItemDragEventArgs メンバ

ListView コントロールと TreeView コントロールの ItemDrag イベントのデータを提供します。

ItemDragEventArgs データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド ItemDragEventArgs オーバーロードされます。 ItemDragEventArgs クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ItemDragEventArgs クラス
System.Windows.Forms 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「ItemDragEventArgs」の関連用語

ItemDragEventArgsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ItemDragEventArgsのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS