Drag-and-Drop Options
- 3 minutes to read
The GridControl has a set of properties and events that allow you to control drag-and-drop operations at different stages.
Common
Use the following properties to enable drag-and-drop operations:
Property | Description |
---|---|
DataViewBase.AllowDragDrop | Gets or sets whether an end user can drag and drop grid view’s records. |
DataViewBase.AllowSortedDataDragDrop | Gets or sets whether an end user can drag and drop sorted or grouped data. |
The GridControl with the drag-and-drop functionality enabled requires 2 mouse clicks to activate a cell editor and 3 clicks to open a drop-down editor. You can set the DataViewBase.EditorShowMode property to MouseDownFocused
or MouseUp
to reduce the number of clicks.
The Beginning of the Drag-and-drop Operation
You can prevent the drag-and-drop operation or customize the dragged data:
Event | Description |
---|---|
DataViewBase.StartRecordDrag | Occurs when a drag-and-drop operation is started. You can use this event to modify dragged data or forbid dragging specific records. |
The Dragging Process
You can specify how your source and target grids behave during the drag-and-drop operation, and customize the drop hint and marker elements’ appearance:
Property | Description |
---|---|
DataViewBase.AutoExpandOnDrag | Gets or sets whether dragging records over a collapsed group automatically expands this group. |
DataViewBase.AutoExpandDelayOnDrag | Gets or sets the delay after which the collapsed group is expanded, in milliseconds. |
DataViewBase.AllowScrollingOnDrag | Gets or sets whether dragging records to the edges of the grid’s view automatically activates scrolling. |
DataViewBase.ShowDragDropHint | Gets or sets whether the drag-and-drop hint is displayed when dragging a record. |
DataViewBase.ShowTargetInfoInDragDropHint | Gets or sets whether the drag-and-drop hint shows information about a drop target. |
DataViewBase.DragDropHintTemplate | Gets or sets the template that defines the drag-and-drop hint‘s presentation. |
DataViewBase.DropMarkerTemplate | Gets or sets the template that defines the drop marker‘s presentation. |
Event | Description |
---|---|
DataViewBase.DragRecordOver | Occurs continuously while a record is dragged within the drop target’s boundary. You can use this event to check dragged data availability, deny a drop operation over specific records, or set a drop position. |
DataViewBase.GiveRecordDragFeedback | Occurs continuously during a drag-and-drop operation and enables the drop source to give feedback to the user. |
DataViewBase.ContinueRecordDrag | Occurs when there is a change in the keyboard or mouse button states during a drag-and-drop operation, and enables the drop source to cancel the drag-and-drop operation depending on the key/button states. |
The End of the Drag-and-drop Operation
You can reorder items, customize dropped data, and prevent removing the dragged items from the source grid:
Event | Description |
---|---|
DataViewBase.DropRecord | Occurs when a record is dropped on the target element. You can use this event to process dropped data. |
DataViewBase.CompleteRecordDragDrop | Occurs when a drag-and-drop operation is completed. You can use this event to cancel removing records after dropping or add additional actions. |
Tip
For the ListBoxEdit, you can use the ListBoxDragDropBehavior class’s attached properties and events. Refer to the Drag-and-Drop Between GridControl and ListBoxEdit topic for more information.