ItemDragEventArgs.Item Propiedad

Definición

Obtiene el elemento que se está arrastrando.

public:
 property System::Object ^ Item { System::Object ^ get(); };
public object Item { get; }
public object? Item { get; }
member this.Item : obj
Public ReadOnly Property Item As Object

Valor de propiedad

Objeto que representa el elemento que se está arrastrando.

Ejemplos

En el ejemplo siguiente se muestra el uso de al habilitar operaciones de ItemDragEventArgs arrastrar y colocar dentro de un TreeView control . La Button propiedad determina si el nodo arrastrado se debe mover o copiar en su destino. El nodo, representado por la Item propiedad , se pasa al TreeView método del DoDragDrop control junto con un valor que indica el efecto deseado de la operación de arrastrar y colocar.

Para obtener el ejemplo completo, consulte el tema de TreeView.ItemDrag referencia.

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

Comentarios

Puede usar esta propiedad para determinar qué elemento de los TreeView controles o ListView se está arrastrando desde el control.

Se aplica a