ItemDragEventArgs.Item Własność
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
Pobiera element, który jest przeciągany.
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
Wartość nieruchomości
Obiekt reprezentujący przeciągany element.
Przykłady
Poniższy przykład ilustruje użycie ItemDragEventArgs podczas włączania operacji przeciągania i upuszczania w kontrolce TreeView . Właściwość Button określa, czy przeciągnięty węzeł powinien zostać przeniesiony, czy skopiowany do 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 operacji przeciągania i upuszczania.
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
Za pomocą tej właściwości można określić, który element z TreeView kontrolek lub ListView jest przeciągany z kontrolki .