ItemDragEventArgs Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public ref class ItemDragEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class ItemDragEventArgs : EventArgs
public class ItemDragEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type ItemDragEventArgs = class
inherit EventArgs
type ItemDragEventArgs = class
inherit EventArgs
Public Class ItemDragEventArgs
Inherits EventArgs
- Inheritance
- Attributes
Examples
The following example illustrates the use of ItemDragEventArgs when enabling drag-and-drop operations within a TreeView. The Button property determines whether the dragged node should be moved or copied to its destination. The node, represented by the Item property, is then passed to the TreeView control's DoDragDrop method along with a value indicating the desired effect.
For the complete example, see the TreeView.ItemDrag reference topic.
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
Remarks
The ItemDrag event occurs when the user begins dragging an item. An ItemDragEventArgs object specifies which mouse button was pressed.
Constructors
ItemDragEventArgs(MouseButtons) |
Initializes a new instance of the ItemDragEventArgs class with a specified mouse button. |
ItemDragEventArgs(MouseButtons, Object) |
Initializes a new instance of the ItemDragEventArgs class with a specified mouse button and the item that is being dragged. |
Properties
Button |
Gets a value that indicates which mouse buttons were pressed during the drag operation. |
Item |
Gets the item that is being dragged. |
Methods
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |