Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Prevent drag/drop to Root node  (Read 712 times)

0 Members and 1 Guest are viewing this topic.

swbarlow

  • Customer
  • Newbie
  • *
  • Offline Offline
  • Posts: 2
Prevent drag/drop to Root node
« on: December 09, 2009, 02:44:19 PM »
I am evaluating the Treeview, and so far does everytihng I need it to do, however I do have one problem

My tree is a simple one.. {Root Node} - (Parent Nodes) - (Child Nodes).

Moving Child Nodes to other Parent Nodes works great, but I need the ability to prevent the movement of child node to the Root node, which creates another parent node.

Is this possible, if so how.


Ruslan

  • Flexible TreeView Team
  • Sr. Member
  • *****
  • Offline Offline
  • Posts: 496
Re: Prevent drag/drop to Root node
« Reply #1 on: December 09, 2009, 03:42:28 PM »
Hello,

Welcome to forums and thank you for your interest to our product.

You can completely control the drag&drop behavior. If by {Root Node} you mean the tree.Root property (tree`s root invisible node) then to accomplish that subscribe to the DragOver event with this code:
Code: [Select]
void tree_DragOver(object sender, DragEventArgs e)
{
  FlexibleTreeView tree = (FlexibleTreeView) sender;
  e.Effect = (tree.DragDropState.RealNode != null) ? DragDropEffects.Move : DragDropEffects.None;
}

tree.DragDropState.RealNode is a node where nodes being dragged will be dropped. It has NULL value when user trying to drop nodes to the treeview empty space, i.e. to the Root treeview node. So here we prevent to do that.

Feel free to contact us if need deeper explanation.

swbarlow

  • Customer
  • Newbie
  • *
  • Offline Offline
  • Posts: 2
Re: Prevent drag/drop to Root node
« Reply #2 on: December 09, 2009, 03:55:08 PM »
Perfect works great, knew it would be simple

For those in VB

Code: [Select]
   
Private Sub FlexTree_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles FlexTree.DragOver
        Dim tree As FlexibleTreeView = DirectCast(sender, FlexibleTreeView)
        If tree.DragDropState.RealNode Is Nothing Then
            e.Effect = DragDropEffects.Move & DragDropEffects.None
        End If
    End Sub

Ruslan

  • Flexible TreeView Team
  • Sr. Member
  • *****
  • Offline Offline
  • Posts: 496
Re: Prevent drag/drop to Root node
« Reply #3 on: December 09, 2009, 04:10:51 PM »
Glad to hear it works for you.

Feel free to contact us if you have any other questions.
 

Copyright © 2006-2012 ARMSoft. All rights reserved.