Only allow drop as child on root node

2 posts, 1 answers
  1. King Du
    King Du avatar
    12 posts
    Member since:
    Jun 2005

    Posted 01 Mar 2012 Link to this post

    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!
  2. Answer
    Svett avatar
    728 posts

    Posted 06 Mar 2012 Link to this post

    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.

    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top