1

I'm implementing a TreeControl using the DotNetBar Advtree component. However I seem to be struggling to find the property to make it impossible for a particular node to have any children. What I want to stop the following below;

How to stop this with the TreeControl component?

For example an RSS feed cannot be contained with an RSS feed. Some in effect I want some nodes to be draggable, and can have children, and others only draggable.

enter image description here

Thanks for any help. I've noticed the property NodesIndent which I've setting to -1, or 5000 but neither was any help.

wonea
  • 4,783
  • 17
  • 86
  • 139
  • The docs that atkon link seem to suggest that you would subscribe to NodeDragFeedback event or BeforeNodeDrop event and cancel the action If it's an invalid location – wdavo Sep 10 '12 at 08:38
  • Yes, that's what I'm struggling with. I have different node types for each node on the tree, comparing them works fine with NodeDragFeedback but I can't reorder the nodes to wanted to find a different way; stopping a node from having children. – wonea Sep 10 '12 at 09:16

2 Answers2

2

According to http://www.devcomponents.com/kb2/?p=327, there is a DragDropEnabled property to control this. If that does not work, handle the BeforeNodeDragStart event and cancel the drag.

[Edit: Added the following]

To prevent dragging a node under certain nodes and not others, handle the BeforeNodeDrop event and setting Cancel=true if the node being dragged cannot be added as a child to the destination node.

akton
  • 14,148
  • 3
  • 43
  • 47
  • I've figured out how to enable/disable particular tree nodes from being dragged, but what I want is to declare that certain nodes can have children and others can't. – wonea Sep 10 '12 at 08:24
  • @wonea I have added more information to the answer. Does this help? – akton Sep 10 '12 at 08:38
  • Yes, I do a type comparison. A derive nodes for different type, say RSSNode : Node, and InboxNode : Node. This is fine but it falls down as I can't reorder the nodes, so my only option seems to be disable the child drop somehow. – wonea Sep 10 '12 at 09:13
1

Just spotted in the documentation;

“Gets or sets the new insert position inside of NewParentNode.Nodes collection for the node being dragged. If InsertPosition is -1 the ParentNode refers to the current mouse over node and drag & drop node will be added as child node to it.”

So basically I can capture whether or not it is being added to as child node, compare the node type and decide whether to accept the drop.

wonea
  • 4,783
  • 17
  • 86
  • 139