ItemDragEventArgs.Item Свойство

Определение

Получает перетаскиваемый элемент.

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

Значение свойства

Объект, представляющий перетаскиваемый элемент.

Примеры

В следующем примере показано использование при включении операций ItemDragEventArgs перетаскивания в элементе TreeView управления . Свойство 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

Комментарии

Это свойство можно использовать, чтобы определить, какой элемент из TreeView элементов управления или ListView перетаскивается из элемента управления .

Применяется к