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

Drag Item out of TreeView

4 Answers 88 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 06 Jun 2008, 11:44 PM
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.

4 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 09 Jun 2008, 02:20 PM
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
0
Andreas
Top achievements
Rank 1
answered on 09 Jun 2008, 03:41 PM
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.
0
Andreas
Top achievements
Rank 1
answered on 09 Jun 2008, 03:47 PM
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
0
Jordan
Telerik team
answered on 12 Jun 2008, 08:01 AM
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
Tags
Treeview
Asked by
Andreas
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or