ItemDragEventArgs.Button プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

MouseButtons 値のビットごとの組み合わせ。

このプロパティを使用すると、ドラッグ アンド ドロップ操作中にどちらのマウス ボタンが押されたかを判断できます。このプロパティの値を使用すると、ドラッグ アンド ドロップ操作をどのように実行するかを正しく判断できます。たとえば、マウスの左ボタンが押された場合は項目を新しい場所に移動し、マウスの右ボタンが押された場合は項目を新しい場所にコピーできます。

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からItemDragEventArgs.Button プロパティを検索する場合は、下記のリンクをクリックしてください。

- ItemDragEventArgs.Button プロパティのページへのリンク