Drag Drop Treeview to Grid

7 posts, 0 answers
  1. Manikandan
    Manikandan avatar
    13 posts
    Member since:
    Apr 2009

    Posted 23 Jun 2009 Link to this post

    How to drag a node from Treeview and drop in Radgrid ?
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 23 Jun 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 03 Nov 2009 Link to this post

    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
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 05 Nov 2009 Link to this post

    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.
  6. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 23 Nov 2009 Link to this post

    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

  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 25 Nov 2009 Link to this post

    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.
  8. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 25 Nov 2009 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready