ToolboxControl.DragItemStart Event
Fires when an item’s drag operation starts. Allows you to replace the cursor icon and cancel the drag operation.
Namespace: DevExpress.XtraToolbox
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Event Data
The DragItemStart event's data class is ToolboxDragItemStartEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets whether a drag-and-drop operation should be canceled. |
Handled | Gets or sets whether an event was handled; if handled, the default actions are not required. |
Image | Gets or sets the image displayed near the mouse cursor during drag-and-drop operations. |
Remarks
The ToolboxControl provides you with events that allow you to manage a drag-and-drop operation during all its stages: the operation on an item is started, the item is being dragged, and the item has been dropped. The events below correspond to each stage of a drag-and-drop operation:
The DragItemStart event — fires when an end-user starts a drag-and-drop operation, and allows you to cancel the action. For this purpose, set the ToolboxDragItemStartEventArgs.Cancel property to true. If this event is canceled, the subsequent ToolboxControl.DragItemMove and ToolboxControl.DragItemDrop events do not fire.
If the event is not canceled, using the ToolboxDragItemStartEventArgs.Image property, you can replace the item icon displayed near the mouse cursor during the drag-and-drop operation. Note that the ToolboxDragItemStartEventArgs.Handled property should be set to true for the event to be handled.
The ToolboxControl.DragItemMove event — fires during the mouse generating event, and allows you to cancel the action. For this purpose, set the ToolboxDragItemMoveEventArgs.Cancel property to true. You can at this stage determine the location of the mouse pointer, and provide feedback to an end-user on whether the item can be dropped at this point by specifying the drag-and-drop effect.
The ToolboxDragItemMoveEventArgs.Location property returns the x- and y- coordinates of the mouse pointer relative to the upper-left screen corner. The ToolboxDragItemMoveEventArgs.DragDropEffects property allows you to specify the mouse cursor for a particular target of the drag-and-drop operation. For instance, you can display the circle-backslash symbol if the target does not accept data.
- The ToolboxControl.DragItemCancel event — fires when a drag operation is canceled. Users can press the Esc key to cancel a drag operation. You can use a drag event’s Cancel argument to cancel an operation.
- The ToolboxControl.DragItemDrop event — fires when the item has been dropped, and allows you to perform custom actions.
At all stages of the drag-and-drop operation, you can get access to the collection of items on which the operation is performed using the Items event argument. The Item event argument returns the first item in the collection.