ItemDragEventArgs.Button 속성

정의

끌기 작업 동안 어떤 마우스 단추를 눌렀는지를 나타내는 값을 가져옵니다.

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 값의 비트 조합입니다.

예제

다음 예제에서는 컨트롤 내에서 끌어서 놓기 작업을 사용할 때 클래스를 사용하는 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

설명

이 속성을 사용하면 끌어서 놓기 작업 중에 누른 마우스 단추를 확인할 수 있습니다. 이 속성의 값을 사용하여 끌어서 놓기 작업을 수행하는 방법을 올바르게 결정할 수 있습니다. 예를 들어 마우스 왼쪽 단추를 누를 때 항목을 새 위치로 이동하고 오른쪽 마우스 단추를 누를 때 새 위치에 복사할 수 있습니다.

적용 대상