Tree View drag and drop issues

2 posts, 0 answers
  1. Sayyed
    Sayyed avatar
    1 posts
    Member since:
    Nov 2011

    Posted 28 Nov 2011 Link to this post

    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.
  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 01 Dec 2011 Link to this post

    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()
                Dim form2 As New Form()
                textBox = New TextBox()
                textBox.AllowDrop = True
                AddHandler textBox.DragDrop, New DragEventHandler(AddressOf textBox_DragDrop)
                AddHandler textBox.DragOver, New DragEventHandler(AddressOf textBox_DragOver)
            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
                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.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.

    Julian Benkov
    the Telerik team

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

  3. DevCraft R3 2016 release webinar banner
Back to Top