Results 1 to 4 of 4

Thread: Treeview Drag And Drop (Copy)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    68

    Treeview Drag And Drop (Copy)

    Is it possible to copy treenodes between treeviews using drag and drop?

    I can easily move a node from tree1 to tree2, but I can't get it to stay in tree1.

    I've used example code from: http://www.codeproject.com/vb/net/Tr...ragAndDrop.asp

    Changing the e.Effect = DragDropEffects.Move into Copy wasn't enough, and removing the line "dropNode.Remove()" also doesn't work, it makes the drag en drop unresponsive.

    Any help would be appreciated.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    68

    Re: Treeview Drag And Drop (Copy)

    Anyone?

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Treeview Drag And Drop (Copy)

    You cannot have the same TreeNode in two TreeViews. If you want to copy a node from one tree to another then when it comes time to drop you'll need to Clone your TreeNode and add that to the second tree rather than adding the node that was originally dragged. Either that or create a Clone when the drag starts and make that the Data that is being dragged. I go for the first option though because there's no point Cloning the node if the operation is cancelled part way.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    68

    Re: Treeview Drag And Drop (Copy)

    Thanks a bunch.

    I had already tried assigning them to another treenode and adding that, but that didn't work either ofcourse.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width