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

Radtreenode get location

1 Answer 148 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Anuj
Top achievements
Rank 1
Anuj asked on 30 Jun 2014, 05:39 AM
Hi,

I am using telerik Radtreeview. and i am performing drag and drop from radtreeview to RadScrollablePanel.
it is working fine but i the treenode which i drag and drop in panel goes to top-left location every time.
i want to place it where i leave the cursor.
means the location of treenode when i drop should be the where i leave my cursor.
(like google map pin).

Please reply.

Thanks
Anuj

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 02 Jul 2014, 01:18 PM
Hello Anuj,

Thank you for contacting us.

You can set the location of the dropped element in the PreviewDragDrop event. For example you can perform the entire drag and drop operation as follows:
public Form1()
{
    InitializeComponent();
    radTreeView1.AllowDragDrop = true;
    radScrollablePanel1.PanelElement.AllowDrop = true;
    radTreeView1.TreeViewElement.DragDropService.PreviewDragOver += DragDropService_PreviewDragOver;
    radTreeView1.TreeViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop;
}
 
void DragDropService_PreviewDragDrop(object sender, Telerik.WinControls.RadDropEventArgs e)
{
    RadScrollablePanelElement element = e.HitTarget as RadScrollablePanelElement;
 
    if (element != null)
    {
        RadLabel label = new RadLabel();
        label.Location = e.DropLocation;
        label.Text = ((TreeNodeElement)e.DragInstance).Data.Text;
        element.ElementTree.Control.Controls.Add(label);
    }
}
 
void DragDropService_PreviewDragOver(object sender, Telerik.WinControls.RadDragOverEventArgs e)
{
    e.CanDrop = e.HitTarget is RadScrollablePanelElement;
}

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Treeview
Asked by
Anuj
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or