Drag-Drop from RadTreeView to custom control

2 posts, 0 answers
  1. PLuS
    PLuS avatar
    1 posts
    Member since:
    May 2015

    Posted 04 May 2015 Link to this post


    I have a RadTreeView with some items inside and want to drag and drop items to a custom control derived from RadControl (which is inside a DocumentWindow in a RadDock).

    I tried to attach TreeViewElement.DragDropService.PreviewDragOver event but it does not fire for my custom control. (Have set AllowDrop to true and tried to implement ISupportDrop interface but no luck)

    Any help would be appreciated.

  2. Dess
    Dess avatar
    1561 posts

    Posted 06 May 2015 Link to this post

    Hello Omid,

    Thank you for writing.

    RadTreeView controls the drag and drop functionality by TreeViewDragDropService. The RadTreeView.AllowDragDrop property should be set to true along with the drop target's AllowDrop property. If the custom control is a derivative of RadControl, the TreeViewDragDropService will search for an RadElement which is ISupportDrop. However, the RadControl is a basic class that does not have such an element. You can add a LightVisualElement or derive from another control, e.g. RadPanel.
    CustomControl c = new CustomControl();
    public Form1()
        c.BackColor = Color.Red;
        c.Size = new System.Drawing.Size(100, 100);
        this.radTreeView1.AllowDragDrop = true;
        this.radTreeView1.TreeViewElement.DragDropService.PreviewDragOver += DragDropService_PreviewDragOver;
        this.radTreeView1.TreeViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop;
    private void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
        LightVisualElement lve = e.HitTarget as LightVisualElement;
        if (lve == null)
        CustomControl c = lve.ElementTree.Control as CustomControl;
        if (c != null)
            c.BackColor = Color.Yellow;
    private void DragDropService_PreviewDragOver(object sender, Telerik.WinControls.RadDragOverEventArgs e)
        e.CanDrop = false;
        if (!(e.HitTarget is TreeNodeElement || e.HitTarget is RadTreeViewElement))
            e.CanDrop = true;
    public class CustomControl : RadControl
        protected override void CreateChildItems(RadElement parent)
            LightVisualElement lve = new LightVisualElement();
            lve.AllowDrop = true;

    I hope this information helps. Should you have further questions, I would be glad to help.

    See What's Next in App Development. Register for TelerikNEXT.

  3. DevCraft R3 2016 release webinar banner
Back to Top