ItemDragEventArgs 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public ref class ItemDragEventArgs : EventArgs
C#
[System.Runtime.InteropServices.ComVisible(true)]
public class ItemDragEventArgs : EventArgs
C#
public class ItemDragEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type ItemDragEventArgs = class
inherit EventArgs
type ItemDragEventArgs = class
inherit EventArgs
Public Class ItemDragEventArgs
Inherits EventArgs
- 继承
- 属性
以下示例演示如何在 中TreeView启用拖放操作时使用 ItemDragEventArgs 。 属性 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 );
}
}
C#
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
当用户 ItemDrag 开始拖动项时发生该事件。 对象 ItemDragEventArgs 指定按下的鼠标按钮。
Item |
用指定的鼠标按钮初始化 ItemDragEventArgs 类的新实例。 |
Item |
用指定的鼠标按钮和正被拖动的项初始化 ItemDragEventArgs 类的新实例。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |