Prevent node opening on Drag Drop

6 posts, 1 answers
  1. Ryan
    Ryan avatar
    10 posts
    Member since:
    Apr 2008

    Posted 02 Jun 2008 Link to this post

    Is there a way to prevent nodes from opening when a node is being dragged over it or to only open when the node is held over the +- portion of the node?

    The opening seems to be almost random as sometimes a node will open while moving past another node and other times you can hold the dragged node over another node for several seconds with nothing happening.
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 03 Jun 2008 Link to this post

    Hi Ryan,

    Thank you for writing.

    You can cancel expanding/collapsing nodes by handling the NodeExpandedChanging event of RadTreeView as shown below:

    private bool treeViewDragging = false
     
    void radTreeView1_DragEnding(object sender, RadTreeViewDragCancelEventArgs e) 
        this.treeViewDragging = false
     
    void radTreeView1_DragStarted(object sender, RadTreeViewDragEventArgs e) 
        this.treeViewDragging = true
     
    void radTreeView1_NodeExpandedChanging(object sender, RadTreeViewCancelEventArgs e) 
        if (this.treeViewDragging) 
        { 
            e.Cancel = true
        } 

    I hope this helps. If you have additional questions, please contact me.

    Kind regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ryan
    Ryan avatar
    10 posts
    Member since:
    Apr 2008

    Posted 05 Jun 2008 Link to this post

    This is how I was originally doing it but there is a problem.  The drag ending/ended event doesn't fire if a node is dropped off of the treeview.  Is there a workaround to take into account the user cancelling the drag drop by dropping the node outside of the treeview?
  5. Ryan
    Ryan avatar
    10 posts
    Member since:
    Apr 2008

    Posted 05 Jun 2008 Link to this post

    I looked in the source code for the RadTreeView and the ResetDragging function gets called if a drag is cancelled and this function does not trigger the Drag Ending or Drag Ended events.  Is there a reason that this does not happen or would it be safe for me to add this functionality into the ResetDragging function?
  6. Answer
    Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 06 Jun 2008 Link to this post

    Hi Ryan,

    You could try adding this functionality into the ResetDragging function, but I recommend against it. The reason is, you'll have to modify the source of RadTreeView, and we we would not be able to support the component in your case, as per the license agreement. I recommend using the MouseUp event (which is always fired, and is fired after the drag and drop operation ends) of RadTreeView instead of the DragEnding event.

    Currently, the DragEnding and DragEnded pair of events is used to notify of a successful drag of a node.
    You are correct - currently, there is no way to know when a drag and drop operation ends unsuccessfuly. We will add such an event for the upcomming 2008 Q2 release to handle this scenario.

    Your Telerik points have been updated. Contact us again if you have any further questions.

    Best wishes,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Ryan
    Ryan avatar
    10 posts
    Member since:
    Apr 2008

    Posted 06 Jun 2008 Link to this post

    Thank you the MouseUp event works for what I need
Back to Top
UI for WinForms is Visual Studio 2017 Ready