Example Drag and drop Between 2 Treeviews VB.net

6 posts, 0 answers
  1. Ludo
    Ludo avatar
    3 posts
    Member since:
    Oct 2014

    Posted 22 Sep 2015 Link to this post

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

     

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 22 Sep 2015 Link to this post

    Hello Ludo,

    Thank you for writing.

    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. 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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ludo
    Ludo avatar
    3 posts
    Member since:
    Oct 2014

    Posted 23 Sep 2015 in reply to Dess Link to this post

    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

     

     

     

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 24 Sep 2015 Link to this post

    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
  6. Ludo
    Ludo avatar
    3 posts
    Member since:
    Oct 2014

    Posted 27 Sep 2015 in reply to Dess Link to this post

    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​

  7. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 28 Sep 2015 Link to this post

    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 in bound 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
Back to Top
UI for WinForms is Visual Studio 2017 Ready