Hello Juan,
To do this you will need to subclass NTreeViewEx and override Apply
DragDrop method as follows:
public class MyNTreeViewEx : NTreeViewEx
{
protected override void ApplyDragDrop(NLightUIItemDragDropEventArgs e)
{
NTreeNode over = e.DragOverItem as NTreeNode;
// condition which determines that this is the node(s) that cannot
// drop another node on it.
// In this case you can set Tag property of the node to true,
// or you can choose another approach.
if ((bool)over.Tag == true)
{
return;
}
base.ApplyDragDrop(e);
}
}
public class MyNTreeViewEx : NTreeViewEx
{
protected override void ApplyDragDrop(NLightUIItemDragDropEventArgs e)
{
NTreeNode over = e.DragOverItem as NTreeNode;
// condition which determines that this is the node(s) that cannot
// drop another node on it.
// In this case you can set Tag property of the node to true,
// or you can choose another approach.
if ((bool)over.Tag == true)
{
return;
}
base.ApplyDragDrop(e);
}
}
Also you can attach the instance of the new class to Item
Drag event and in the event handler you can change the cursor when the user
drag over the node that should not accept
dropped node:
myNTreeViewEx1.ItemDrag += myNTreeViewEx1_ItemDrag;
...
void myNTreeViewEx1_ItemDrag(object sender, NLightUIItemDragDropEventArgs e)
{
NTreeViewEx treeView = sender as NTreeViewEx;
// get the hovered node
NTreeNode node = treeView.VisibleNodeFromY(e.MousePosition.Y);
if (node == null)
{
return;
}
Cursor cur = e.Cursor;
if ((bool)node.Tag == true && e.Cursor == null)
{
e.Cursor = Cursors.No;
}
else
{
e.Cursor = cur;
}
}
myNTreeViewEx1.ItemDrag += myNTreeViewEx1_ItemDrag;
...
void myNTreeViewEx1_ItemDrag(object sender, NLightUIItemDragDropEventArgs e)
{
NTreeViewEx treeView = sender as NTreeViewEx;
// get the hovered node
NTreeNode node = treeView.VisibleNodeFromY(e.MousePosition.Y);
if (node == null)
{
return;
}
Cursor cur = e.Cursor;
if ((bool)node.Tag == true && e.Cursor == null)
{
e.Cursor = Cursors.No;
}
else
{
e.Cursor = cur;
}
}
I hope this helps.
Best Regards,
Nevron Support Team