Drag&Drop: Get Drop-Location of Drop-Element

2 posts, 0 answers
  1. Martin
    Martin avatar
    17 posts
    Member since:
    Nov 2019

    Posted 07 Jan 2020 Link to this post

    Hello and a happy new Year!!!

    I implement a drag&drop-function from RadPanels inside a System.Windows.Forms.FlowLayoutPanel.

    When i come to the DragDrop-Event the "DragEventArgs e" only have the Location (e.X / e.Y) of the display not from the FlowLayoutPanel.

    Where can i get the location of the dropped RadPanel?

    Another question: Is there an event of moving the dragged RadPanel? I didn´t found that. I need this for animation / show the dragged RadPanel.

    Best regards, Martin

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4177 posts

    Posted 08 Jan 2020 Link to this post

    Hello, Martin,   

    To perform drag-and-drop operations within Windows-based applications you must handle a series of events, most notably the DragEnter, DragLeave, and DragDrop events. A sample approach is demonstrated in the following article: https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/walkthrough-performing-a-drag-and-drop-operation-in-windows-forms 

    The DragEventArgs offers the X,Y values in screen coordinates. You can calculate the drop location within the control's bounds by using the PointToClient method: 
            private void radPanel1_DragDrop(object sender, DragEventArgs e)
            {
                Point screenDropLocation = new Point(e.X, e.Y);
                Point dropLocation = this.radPanel1.PointToClient(screenDropLocation);
                Console.WriteLine("Screen drop location :" + screenDropLocation+ " Control drop location:" +dropLocation);
            }
    There is no specific event for moving the dragged RadPanel. However, if you need to simulate animation effect, I would recommend you to have a look at the following help article which demonstrates the available options in the Telerik Presentation Framework: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/animations 

    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

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top