Drag and Drop in Bound Mode
This article demonstrates how you can implement drag and drop operation between two bound RadListControl controls. This example is using the ole drag and drop
Figure 1: The final result.
The drag and drop functionality is achieved with the help of four events: MouseDown, MouseMove, DragEnter, DragDrop:
1. Handling the MouseDown and MouseMove events: The MouseDown event is used for saving the position of the clicked element. It will be used later for getting the element under the mouse. The MouseMove event can be used to start the drag and drop operation. It is started with the DoDragDrop method only if the left mouse button is used and a valid item is clicked.
The IsRealDrag method returns true only if the mouse have moved certain amount of pixels (determined by the operating system).
MouseDown and MouseMove
2. Handling the DragEnter event: This event will fire when the mouse is hovering over a control that allows dropping. Here you can use it to disable the drop operation within the same control.
The DragEnter event handler
3. Handling the DragDrop event: This is the most important event. In it you have access to both, the dragged element and the control where the item is dropped. This allows you to handle the drop operation appropriately according to your specific requirements. In this case, both controls are bound, and this allows you to just add/remove items from/to their data source (the changes will be immediately reflected by the controls).
The DragDrop event handler
Additionally, you should enable the AllowDrop property for both controls. With this example you can move from the first RadListControl to the second and vice versa. Along with this, the following snippet shows how you can bind the controls and subscribe to the events. The same events are used for both controls.
Controls initialization
To complete the example you can use the following sample class.