This is a migrated thread and some comments may be shown as answers.

Drag and Drop cancels DoubleClick Event

2 Answers 519 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 03 Feb 2021, 07:23 PM
If I do a RadTreeView.DoDragDrop in the MouseDown event, the DoubleClick Event never fires.  Is there a way to begin Drag and Drop in MouseDown, and still get the DoubleClick event?  Basically, if it's a DoubleClick, I don't need the MouseDown event, because there is no need to have started the Drag and Drop.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Feb 2021, 10:29 AM
Hello, Terry,  

The MouseDown event is expected to be fired before the DoubleClick event which needs a second click. Then, if the drag and drop operation is already started, it is normal that the DoubleClick event wouldn't be fired while the drag operation is ongoing. I believe that a similar behavior is observed with the Microsoft TreeView.

The possible solution that I can suggest is to start the drag and drop operation at a later moment, e.g. in the MouseMove event. Thus, you can check whether the left mouse button is pressed and determine whether to start the drag operation:
        private Point mouseDownPosition;
        private void RadTreeView1_MouseMove(object sender, MouseEventArgs e)
        { 
            var node = radTreeView1.ElementTree.GetElementAtPoint(mouseDownPosition) as TreeNodeElement;

           
            if (node != null&& e.Button == MouseButtons.Left&&  IsRealDrag(mouseDownPosition, e.Location))
            { 
                radTreeView1.DoDragDrop(node.Data.Text, DragDropEffects.Copy); 
            }
        }
        private static bool IsRealDrag(Point mousePosition, Point initialMousePosition)
        {
            return (Math.Abs(mousePosition.X - initialMousePosition.X) >= SystemInformation.DragSize.Width) || 
                (Math.Abs(mousePosition.Y - initialMousePosition.Y) >= SystemInformation.DragSize.Height);
        }
        private void RadTreeView1_MouseDown(object sender, MouseEventArgs e)
        { 
            this.mouseDownPosition = e.Location;
        }
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Terry
Top achievements
Rank 1
answered on 08 Feb 2021, 10:57 PM
Thanks!  This solution works well for me.
Tags
Treeview
Asked by
Terry
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Terry
Top achievements
Rank 1
Share this question
or