ItemDragEventArgs.Button プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ドラッグ操作中に押されたマウス ボタンを示す値を取得します。
public:
property System::Windows::Forms::MouseButtons Button { System::Windows::Forms::MouseButtons get(); };
public System.Windows.Forms.MouseButtons Button { get; }
member this.Button : System.Windows.Forms.MouseButtons
Public ReadOnly Property Button As MouseButtons
プロパティ値
MouseButtons値のビットごとの組み合わせ。
例
次の例は、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
注釈
このプロパティを使用すると、ドラッグ アンド ドロップ操作中に押されたマウス ボタンを特定できます。 このプロパティの値を使用して、ドラッグ アンド ドロップ操作の実行方法を適切に決定できます。 たとえば、マウスの左ボタンが押されたときに項目を新しい場所に移動し、マウスの右ボタンが押されたときに新しい場所にコピーすることができます。