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

Drag Drop Treeview to Grid

6 Answers 170 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Manikandan
Top achievements
Rank 1
Manikandan asked on 23 Jun 2009, 05:37 AM
How to drag a node from Treeview and drop in Radgrid ?

6 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 23 Jun 2009, 08:38 AM
Hello Manikandan,

There is no automatic mechanism for drag/drop operations between RadControls. You will have to use the standard WindowsForms architecture. You can find more information here.

Best wishes,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
gmendez
Top achievements
Rank 1
answered on 03 Nov 2009, 01:57 PM
Hello Telerik,

I followed your suggestion here and I could get it to work without problems.
Now, I'd like to enhace it further and display the same visual aid that is displayed when using the standard functionality for drag and drop included in RadTreeView. When you drag a node to a different location in the same treeview it looks and feels like you are dragging the real node with that cool transparency effect. But when dragging into a gridview using the standard Winforms mechanisms as you suggested, a boring standard visual aid is shown...
Is it possible at all to have that pretty visual efect and still use the standard Winforms mechanism?
Best regards

Gonzalo
0
Victor
Telerik team
answered on 05 Nov 2009, 02:58 PM
Hi gmendez,

You can customize the cursor by handling GiveFeedback event which is a member of the Control class.
In the arguments you will find a UseDefaultCursors that you need to set to false. After this you can change the cursor to whatever you need. Please refer to this article for further information.

Greetings,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
gmendez
Top achievements
Rank 1
answered on 23 Nov 2009, 05:08 PM
Hello again,


Besides the drag & drop functionality I must allow the user to double click the nodes to copy the objetcs to the gridView, and off course, they are stored inside the Tag property.
I tryed to implement that and I found out that the d&d implementation I did (following directions given in this thread) is interfering.
Somehow, calling the DoDragDrop method inside the NodeMouseDown event handler is preventing the MouseDoubleClick event to fire.
Here is the code:

        private void Form1_Load(object sender, EventArgs e)  
        {  
            RadTreeNode node1 = new RadTreeNode("Double Click works here");  
            RadTreeNode node2 = new RadTreeNode("But it doesn't work here :(");  
            node2.Tag = "This is something different from null";  
            node1.Nodes.Add(node2);  
 
            RadTreeNode root = radTreeView1.Nodes[0];  
            root.Nodes.Add(node1);  
        }  
 
        private void radTreeView1_MouseDoubleClick(object sender, MouseEventArgs e)  
        {              
            MessageBox.Show("Node Double Clicked!");  
        }  
 
        private void radTreeView1_NodeMouseDown(object sender, RadTreeViewMouseEventArgs e)  
        {  
            if (e.Node.Tag != null)  
                 radTreeView1.DoDragDrop(e.Node.Tag, DragDropEffects.Copy);  
        } 

I's it possible at all to copy objects from the tree to the grid using any of both mechanisms ?
Best regards,

Gonzalo

0
Victor
Telerik team
answered on 25 Nov 2009, 01:02 PM
Hello gmendez,

You can easily go around this case with a boolean flag and by calling DoDragDrop() in a slightly different context. For example, you can call it OnMouseMove and make sure that it is called only once with a boolean variable. This is just how Drag & Drop works in Windows Forms in general.

Best wishes,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
gmendez
Top achievements
Rank 1
answered on 25 Nov 2009, 04:45 PM
Hello Victor,

I have already tried something like that but it wasn't exactly as you suggested. I was on the wrong path.
Thanks a lot for the tip.
As my karate sensei told me once: 'The way to knowledge is paved with pain...'   :)
Best regards,

Gonzalo
Tags
Treeview
Asked by
Manikandan
Top achievements
Rank 1
Answers by
Victor
Telerik team
gmendez
Top achievements
Rank 1
Share this question
or