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

Tree View drag and drop issues

1 Answer 162 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Sayyed
Top achievements
Rank 1
Sayyed asked on 28 Nov 2011, 01:01 PM
We are using telerik control in our Excel-Addin Application.

Functional working: we launch a form on clicking the button ("open form") at add-in ribbon.  User will drag the tree nodes to spreadsheet cells.

Issues we face
1. We don't want hint of node when we perform the drag and drop on spreadsheet cell. (Version used 2010.1.10.504)
2. We tried to use the new version DLL from Telerik but some serious issue arises (Version used 2011.2.11.831)
        a. item drag event is getting called multiple times. 
        b. Cursor remains the NO cursor after dragging the node to area of spreadsheet

Code written on item drag event is as follows

Private Sub RadTreeView1_ItemDrag(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles RadTreeView1.ItemDrag
       If Not IsNothing(RadTreeView1.SelectedNode) Then
           Dim strSelected As String = RadTreeView1.SelectedNode.Text
           RadTreeView1.DoDragDrop(" ", Windows.Forms.DragDropEffects.Copy)
           Globals.ThisAddIn.Application.ActiveCell.Value = "LB (" & "" & ControlChars.Quote.ToString() & strSelected & ControlChars.Quote.ToString() & "" & ")"
       End If
End Sub

Please do provide the solution.

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 01 Dec 2011, 08:35 AM
Hello Sayyed,

The new version of RadTreeView control implements a new internal DragDropService that helps us to provide codeless drag and drop operation between more tree views and better drag and drop support to our RadElements. The default standard drag & drop operation also works when the ItemDrag event is handled and DragOver event is handled on the target control. Here is a simple example:

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports Telerik.WinControls.UI
 
Namespace WindowsFormsApplication2
    Public Partial Class Form1
        Inherits Form
        Private treeView As RadTreeView
        Private textBox As TextBox
 
        Public Sub New()
            InitializeComponent()
 
            Dim form2 As New Form()
            textBox = New TextBox()
            form2.Controls.Add(textBox)
            textBox.AllowDrop = True
            AddHandler textBox.DragDrop, New DragEventHandler(AddressOf textBox_DragDrop)
            AddHandler textBox.DragOver, New DragEventHandler(AddressOf textBox_DragOver)
 
            form2.Show()
        End Sub
 
        Private Sub textBox_DragOver(sender As Object, e As DragEventArgs)
            e.Effect = DragDropEffects.Copy
        End Sub
 
        Private Sub textBox_DragDrop(sender As Object, e As DragEventArgs)
            textBox.Text = e.Data.GetData(GetType(String)).ToString()
        End Sub
 
        Private Sub Form1_Load(sender As Object, e As EventArgs)
            treeView = New RadTreeView()
            treeView.Dock = DockStyle.Fill
            Me.Controls.Add(treeView)
 
            Dim node As New RadTreeNode("Node1")
            node.Nodes.Add(New RadTreeNode("Node2"))
            node.Nodes.Add(New RadTreeNode("Node3"))
            node.Nodes.Add(New RadTreeNode("Node4"))
 
            treeView.Nodes.Add(node)
            treeView.ExpandAll()
 
            treeView.AllowDragDrop = True
            treeView.AllowDrop = True
            treeView.ItemDrag += New RadTreeView.ItemDragHandler(AddressOf treeView_ItemDrag)
        End Sub
 
        Private Sub treeView_ItemDrag(sender As Object, e As RadTreeViewEventArgs)
            treeView.DoDragDrop(treeView.SelectedNode.Text, DragDropEffects.Copy)
        End Sub
    End Class
End Namespace

If you continue to experience the issue, please send us a simple project to investigate it locally. Thank you in advance.

Greetings,
Julian Benkov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
Treeview
Asked by
Sayyed
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or