This is a migrated thread and some comments may be shown as answers.

Only allow drop as child on root node

1 Answer 155 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
King Du
Top achievements
Rank 2
King Du asked on 01 Mar 2012, 04:40 PM
I have a tree view control in which I only ever want to have one root node and it can contain as many children as it wants. When it comes to drag and drop how can I allow the user to drop a rule on the root node but only allow it to be dropped as a child of the root rule? Thanks!

1 Answer, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 06 Mar 2012, 09:51 AM
Hi Patrick,

You can use the DragOverNode event of the RadTreeView control to prevent dropping a node at the wrong position. You can use the following code snippet:

private void radTreeView1_DragOverNode(object sender, RadTreeViewDragCancelEventArgs e)
{
    if (e.DropPosition != DropPosition.AsChildNode)
    {
        e.Cancel = true;
    }
}

I hope this helps.

Regards,
Svett
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Treeview
Asked by
King Du
Top achievements
Rank 2
Answers by
Svett
Telerik team
Share this question
or