Sdílet prostřednictvím


ItemDragEventArgs Třída

Definice

Poskytuje data pro ItemDrag událost ListView a TreeView ovládací prvky.

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
Dědičnost
ItemDragEventArgs
Atributy

Příklady

Následující příklad znázorňuje použití ItemDragEventArgs při povolení operací přetažení myší v rámci .TreeView Vlastnost Button určuje, zda má být přetažen uzel přesunut nebo zkopírován do cíle. Uzel reprezentovaný Item vlastností se pak předá TreeView metodě ovládacího prvku DoDragDrop spolu s hodnotou označující požadovaný efekt.

Úplný příklad najdete v referenčním TreeView.ItemDrag tématu.

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

Poznámky

Událost ItemDrag nastane, když uživatel začne přetahovat položku. Objekt ItemDragEventArgs určuje, které tlačítko myši bylo stisknuto.

Konstruktory

Name Description
ItemDragEventArgs(MouseButtons, Object)

Inicializuje novou instanci ItemDragEventArgs třídy pomocí zadaného tlačítka myši a položky, která je přetažena.

ItemDragEventArgs(MouseButtons)

Inicializuje novou instanci ItemDragEventArgs třídy pomocí zadaného tlačítka myši.

Vlastnosti

Name Description
Button

Získá hodnotu, která označuje, která tlačítka myši byla stisknuta během operace přetažení.

Item

Získá položku, která je přetažena.

Metody

Name Description
Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro