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

Drag and drop to a panel - Has this been added?

1 Answer 52 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Bexm
Top achievements
Rank 1
Bexm asked on 03 Jul 2008, 12:55 PM
I have read in the thread below that you were thinking of adding the ability to drag and drop from a treeview to a different control.

I now need to be able to do this, was it ever added?

Thanks

Bex

Previous Thread

http://www.telerik.com/community/forums/thread/b311D-mchta.aspx

1 Answer, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 07 Jul 2008, 02:55 PM
Hello Bexm,

Thank you for contacting us.

Currently we don't entirely support the OLE drag and drop feature in RadTreeView. However, I have prepared you a simple example, which demonstrates how to get the instance of tree node which is dropped on another control. Please refer to the code block below:
  1. Subscribe to the ItemDrag event
       this.radTreeView1.ItemDrag += new Telerik.WinControls.UI.RadTreeView.ItemDragHandler(radTreeView1_ItemDrag); 
         
 

     2.Get the node instance when the drag operation has started
 
        RadTreeNode draggedNode; 
        void radTreeView1_ItemDrag(object sender, RadTreeViewEventArgs e) 
        { 
           draggedNode =  e.Node; 
        } 
      3. Handle the mouseUp handler of RadTreeView and check if the control under the mouse is RadListBox. If the control is RadListBox we add a new ListBoxItem with text equal to the dropped node's one.
void radTreeView1_MouseUp(object sender, MouseEventArgs e) 
        { 
           if (this.radListBox1.Bounds.Contains(e.Location)) 
           { 
               if (draggedNode != null
               { 
                   RadListBoxItem item = new RadListBoxItem(); 
                   item.Text = draggedNode.Text; 
 
                   this.radListBox1.Items.Add(item); 
               }      
           } 
        } 

I hope this helps. If you need more instructions, please feel free to contact me.

Sincerely yours,
Boyko Markov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Treeview
Asked by
Bexm
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Share this question
or