ItemDragEventArgs Klasa

Definicja

Dostarcza dane dotyczące ItemDrag zdarzenia ListView kontrolek i TreeView .

public ref class ItemDragEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class ItemDragEventArgs : EventArgs
public class ItemDragEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type ItemDragEventArgs = class
    inherit EventArgs
type ItemDragEventArgs = class
    inherit EventArgs
Public Class ItemDragEventArgs
Inherits EventArgs
Dziedziczenie
ItemDragEventArgs
Atrybuty

Przykłady

Poniższy przykład ilustruje użycie ItemDragEventArgs podczas włączania operacji przeciągania i upuszczania w obiekcie TreeView. Właściwość Button określa, czy przeciągnięty węzeł powinien zostać przeniesiony, czy skopiowany do jego miejsca docelowego. Węzeł reprezentowany przez Item właściwość jest następnie przekazywany do TreeView metody kontrolki DoDragDrop wraz z wartością wskazującą żądany efekt.

Pełny przykład można znaleźć w temacie referencyjnym 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

Uwagi

Zdarzenie ItemDrag występuje, gdy użytkownik zaczyna przeciągać element. Obiekt ItemDragEventArgs określa, który przycisk myszy został naciśnięty.

Konstruktory

ItemDragEventArgs(MouseButtons)

Inicjuje ItemDragEventArgs nowe wystąpienie klasy za pomocą określonego przycisku myszy.

ItemDragEventArgs(MouseButtons, Object)

Inicjuje ItemDragEventArgs nowe wystąpienie klasy za pomocą określonego przycisku myszy i przeciąganego elementu.

Właściwości

Button

Pobiera wartość wskazującą, które przyciski myszy zostały naciśnięte podczas operacji przeciągania.

Item

Pobiera element, który jest przeciągany.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy