UI WinForms - Drag and Drop objects over radpageviewpage

1 Answer 67 Views
PageView Treeview
Alain
Top achievements
Rank 1
Alain asked on 26 Jan 2023, 11:43 AM

Hi there,

I do have a RadPageView control on my form.

Each page in the RadPageView control contains a RadTreeView control.

I need to drag a node from one RadTreeView control to another.

How to?

Thank you

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Jan 2023, 01:05 PM

Hello, Alain,

The following help article demonstrates a sample approach how to achieve drag and drop behavior between two RadTreeView controls:

https://docs.telerik.com/devtools/winforms/controls/treeview/drag-and-drop/modify-the-dragdropservice-behavior 

However, note that the two controls should be somehow visible in order to start dragging from the source control and drop to the target control. It may be required to switch the selected page while the dragging operation is being executed.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Alain
Top achievements
Rank 1
commented on 26 Jan 2023, 01:38 PM

Thank you Dess

But that's my main problem, how to get the hovered dragged page tab to be selected?

How do I access the tab control itself? So I could be setting the dragover event handler

This way the other control gets visible and the rest is easy...

Thank you

Dess | Tech Support Engineer, Principal
Telerik team
commented on 27 Jan 2023, 10:14 AM

Hello, Alain,

In the TreeViewElement.DragDropService.PreviewDragOver event you have access to the HitTarget. Hence, when you drag over a RadPageViewStripItem, you can set the RadPageView.SelectedPage to the respective page: 
        public RadForm1()
        {
            InitializeComponent();

            this.radTreeView1.AllowDragDrop = true;
            RadPageViewStripElement stripElement = this.radPageView1.ViewElement as RadPageViewStripElement;
            foreach (RadPageViewStripItem item in stripElement.Items)
            {
                item.AllowDrop = true;
            }
            this.radTreeView1.TreeViewElement.DragDropService.PreviewDragOver += DragDropService_PreviewDragOver;
        }

        private void DragDropService_PreviewDragOver(object sender, RadDragOverEventArgs e)
        {
            Console.WriteLine(e.HitTarget);

            RadPageViewStripItem stripItem = e.HitTarget as RadPageViewStripItem;
            if (stripItem != null)
            {
                e.CanDrop = true;
                this.radPageView1.SelectedPage.Visible = true;
                this.radPageView1.SelectedPage = stripItem.Page;

            }
        }
Tags
PageView Treeview
Asked by
Alain
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or