ItemDragEventArgs.Item 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取正在拖动的项。
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
属性值
一个对象,表示正在拖动的项。
示例
下面的示例演示了在控件中TreeView启用拖放操作时使用的用法ItemDragEventArgs。 该 Button 属性确定拖动的节点是应移动还是复制到其目标。 然后,由属性表示Item的DoDragDrop节点连同指示拖放操作所需效果的值一TreeView起传递给控件的方法。
有关完整示例,请参阅 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
注解
可以使用此属性来确定从控件拖动的项或ListView控件中的项TreeView。