Drag Item out of TreeView

5 posts, 0 answers
  1. Andreas
    Andreas avatar
    6 posts
    Member since:
    Nov 2007

    Posted 06 Jun 2008 Link to this post

    I want to support dragging a RadTreeNode out of a TreeView, but do not want to allow users to drag and drop nodes between other nodes in the same tree.

    this.radTreeView1.ItemDrag += new RadTreeView.ItemDragHandler(radTreeView1_ItemDrag);  
     
    RadTreeNode draggingItem = e.Node;  
     
                if (GetTagValue(draggingItem.Tag.ToString(), "Type") == "Document")  
                {  
                    DataObject dragData = GetDragDropFile(draggingItem);  
                    if (dragData != null)  
                    {  
                        this.DoDragDrop(dragData, DragDropEffects.Copy);  
                    }  
                    else 
                    {  
                        MessageBox.Show("There was a problem with this file.  Please check to make sure you have access, and that you have recently refreshed the Outlook View.""Error...", MessageBoxButtons.OK, MessageBoxIcon.Error);  
                    }  
                } 

    The above code works great as long as I have the AllowDragDrop enabled on the treeview, but then again, it causes problems with nodes being able to be dragged around.

    Any help would be appreciated.
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 09 Jun 2008 Link to this post

    Hi Andreas,

    Thank you for writing.

    If you do not want nodes to be dragged around, you can cancel the drag and drop operations by handling the DragEnding event of RadTreeView as shown below:

    void radTreeView1_DragEnding(object sender, RadTreeViewDragCancelEventArgs e) 
        e.Cancel = true

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

    Best wishes,
    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. Andreas
    Andreas avatar
    6 posts
    Member since:
    Nov 2007

    Posted 09 Jun 2008 Link to this post

    I have tried this approach already, but this does not allow items from this tree to be dragged out of the tree.  I still need the ability to drag items out of this control.  I still have the ItemDrag event defined, but the event is not fired.
  5. Andreas
    Andreas avatar
    6 posts
    Member since:
    Nov 2007

    Posted 09 Jun 2008 Link to this post

    Sorry, I have tried this approach again, it seems that the placement of assigning the events matters.  I am creating a treeview in a webservice, and then returning the XML, then loading this into a client radtreeview.  When this approach is used, items are allowed to be dragged out, but all of the animations for drag/drop in the tree are enabled, and this is very undesired.

    Is there another way to disable this action?

    Thanks
  6. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 12 Jun 2008 Link to this post

    Hi Andreas,

    Another way to disable node dragging, is to disable the drag and drop functionality of RadTreeView altogether. However, you will then have to implement that yourself using the standard drag and drop functionality in Windows Forms.

    If by "animations for drag/drop", you mean the guides indicating what is being dragged and where it will be dropped, you can disable them as shown below:

    this.radTreeView1.ShowFeedbackForm = false
    this.radTreeView1.ShowOutlineFeedbackForm = false

    I hope this helps.

    Sincerely yours,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready