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

Drag and Drop - Stop removing selected treenodeitem from the tree

3 Answers 76 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
anwar
Top achievements
Rank 1
anwar asked on 28 Aug 2009, 06:07 PM

We are using the Radtreeview  control in our Query Builder application to show  the Tables and Fields from the Dtabase . The user can drag and drop the fields in to Selection list (select clause - listbox) and Condition list (where clause - listbox).  When i drag and drop  the field in to Selection list or Condition list, the selected treeview item(field) removed from the RadTreeView. I want to use the same field in both the lists.  

How to achive that in RadTreeview?

 
Thanks,

3 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 29 Aug 2009, 02:12 PM
Hello anwar,

You can register for the PreviewDragEnded event of the TreeView and handle it. Then the default action on drop will not happen and the item will not be removed from the TreeView.

Please note that in this case you should be careful not to get two same items (same reference) in one ItemsControl because then it will stop working correctly.

Sincerely yours,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
anwar
Top achievements
Rank 1
answered on 03 Sep 2009, 01:49 PM
Hello Miroslav,

Thanks for your response, Can you please post the sample code for me.

Thanks,
Anwar
0
Miroslav
Telerik team
answered on 07 Sep 2009, 01:51 PM
Hello Anwar,

Here is the code for it:

treeView.PreviewDragEnded += new RadTreeViewDragEndedEventHandler(treeView_PreviewDragEnded);

And the handler itself:

void allProductsView_PreviewDragEnded(object sender, RadTreeViewDragEndedEventArgs e)
{
    var treeViewItemDestination = e.TargetDropItem;
    //We want to cancel removing the item only if it is dropped outside the current TreeView.
    if (treeViewItemDestination == null || treeViewItemDestination.ParentTreeView != sender)
    {
        e.Handled = true;
    }
}


Hopefully this will help you,

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
anwar
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
anwar
Top achievements
Rank 1
Share this question
or