Earlier this week, I ran across a forum post asking about how one would go about creating multiple RadListBoxes that supported multi-item drag and drop. This sounded like a fun challenge, so I decided to take it on. Referencing an earlier forum post that described single-item drag and drop, I came up with the following solution.
Calling DoDragDrop() immediately changes the mouse pointer and readies the RadListBox for the drag-and-drop operation. Originally, I had tried calling this function in the MouseDown event, but this lead to unpredictable clunky behavior due to the fact that DoDragDrop() was getting called before I had the chance to select multiple items. In the following code, I’ve set up the DoDragDrop() method to get called in the MouseMove event when the mouse button is currently down. I also made sure to keep track of in-progress drag operations in order to prevent calling the DoDragDrop() method hundred of times. (Note: Both RadListBoxes must be subscribed to these events)
In the DragDrop event, I simply iterated through the list of RadItems I passed to the event through the DoDragDrop() method, swapping each item from its former RadListBox to the new RadListBox.
Try it out yourself, or click here to download the source code!
Subscribe to be the first to get our expert-written articles and tutorials for developers!