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

Example Drag and drop Between 2 Treeviews VB.net

5 Answers 279 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Ludo
Top achievements
Rank 1
Ludo asked on 22 Sep 2015, 10:04 AM

is there en example existing for drag and drop operation between 2 RadTreeviews, but not with a move , but Copy operation.

 

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Sep 2015, 11:50 AM
Hello Ludo,

Thank you for writing.

RadTreeView handles the whole drag and operation by its TreeViewDragDropService. The OnPreviewDragOver method allows you to control on what targets the nodes, being dragged, can be dropped on. The OnPreviewDragDrop method initiates the actual physical move or copy of the nodes from one position to another. You can refer to TreeView >> Drag and Drop section in the online documentation. I have prepared a sample project for your convenience which result is illustrated on the attached gif file. Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it on a way which suits your requirement best.

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ludo
Top achievements
Rank 1
answered on 23 Sep 2015, 06:40 PM

Hi,

Thank you for your response, but my programming skills in C# are not so good, can you create an example in VB.Net?

Kind regards

Ludo

 

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Sep 2015, 08:01 AM
Hello Ludo,

Thank you for writing back.
 
Please find attached the sample project in VB.NET. Feel free to use the online Code Converter when you need to convert from C# to VB.NET and vice versa.
 
I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ludo
Top achievements
Rank 1
answered on 27 Sep 2015, 07:11 AM

hi, thank you for the example, I have changed the sub new with:

    Sub New()
         
        InitializeComponent()

        'Dim products As New BindingList(Of Product)()
        'products.Add(New Product(567, "Bicycle", 5))
        'products.Add(New Product(456, "Car", 5000))
        'products.Add(New Product(789, "Bike", 1500))
        'products.Add(New Product(754, "Motor-cycle", 1500))
        'RadTreeView1.DataSource = products
        'RadTreeView1.DisplayMember = "Description"

        'Me.RadTreeView1.AllowDragDrop = True
        ''this.radTreeView1.MultiSelect = true;

        'Dim products2 As New BindingList(Of Product)()
        'products2.Add(New Product(567, "T-shirt", 5))
        'products2.Add(New Product(456, "Jacket", 5000))
        'products2.Add(New Product(789, "Jeans", 1500))
        'Me.RadTreeView2.DataSource = products2
        'Me.RadTreeView2.DisplayMember = "Description"
        Dim node As RadTreeNode
        node = New RadTreeNode
        node.Text = "BE1"
        RadTreeView1.Nodes.Add(node)
        node = New RadTreeNode
        node.Text = "BE"
        RadTreeView2.Nodes.Add(node)
    End Sub

 

then this doesn't seems to work, should the datasource property be used for this to work?

 

kind regards

Ludo​

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Sep 2015, 10:17 AM
Hello Ludo,

Thank you for writing back.

The provided sample project from my previous post just illustrates a sample approach how to handle drag and drop operation between two RadTreeView controls mode.  As noted before, RadTreeView handles the whole drag and drop operation by its TreeViewDragDropService. The OnPreviewDragOver method allows you to control on what targets the nodes, being dragged, can be dropped on. The OnPreviewDragDrop method initiates the actual physical move or copy of the nodes from one position to another. Feel free to modify the provided project on a way which suits your requirement best. When you use unbound mode, you should insert/remove nodes from the respective Nodes collection as the DataBoundItem is null in this case.

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Treeview
Asked by
Ludo
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Ludo
Top achievements
Rank 1
Share this question
or