Drag and Drop from RadTreeView to RadDock

1 Answer 24 Views
Dock Treeview
Hayley
Top achievements
Rank 1
Hayley asked on 20 Mar 2024, 08:07 AM
Hello,

I have a RadTreeView control and a RadDock control together in a WinForms app. The user needs to be able to drag a node from the RadTreeView to either the DocumentTabStrip part of RadDock or the control thats in a DocumentWindow. How do I tell which part of the RadDock the node is being dropped on? Im currently using the  TreeViewElement.DragDropService to handle the PreviewDragDrop method but the RadDropEventArgs.HitTarget gives me a RadPageViewStripElement regardless of where i drop the node. If I am dropping in the content area of the a document window (floating or docked) how do i get the actual DocumentWindow object itself?

Let me know if more information is required.

Thanks,

Hayley

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 21 Mar 2024, 12:21 PM

Hello Hayley,

What comes to my mind is to get the control of the document area. Then you can check its parent which will be the DocumentWindow. I have prepared a sample project to demonstrate what I have in mind. In a few words, there is a RadGridView in the DocumentWindow. Dragging over the grid cell, I am able to get the parent DocumentWindow. You can extend the approach by docking the RadGridView to Fill to take all the available space. 

Give this a try and let me know if it works for you. If not can you modify the project to mimic your setup and will try to find a suitable solution?

Regards,
Dinko | Tech Support Engineer
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.

Hayley
Top achievements
Rank 1
commented on 25 Mar 2024, 04:59 AM

Hi Dinko,

Thanks for your response and the example. The problem we have is that we don't know what the control in the document window is (There are many possible controls it could be). It is also not a Telerik control like a RadGridView which is why when you try and drag and drop onto the control in the Document Window the HitTarget is always a RadPageViewStripElement object. Is there some way that from this object you can get the related DocumentWindow instance and therefore i could access its Controls collection?

Thanks,

Hayley
Dinko | Tech Support Engineer
Telerik team
commented on 27 Mar 2024, 01:26 PM

After trying different approaches, I think I was able to come up with a solution. Your question was the key I needed. Is possible to get the label inside the RadPageViewStripElement which holds the text of the DocumentWindow tab? Here is how you can get it:

private void DragDropService_PreviewDragOver(object sender, Telerik.WinControls.RadDragOverEventArgs e)
{
    RadPageViewTabStripElement tabStripElement = e.HitTarget as RadPageViewTabStripElement;
    if (tabStripElement != null)
    {
        RadPageViewLabelElement label = tabStripElement.Children.Last() as RadPageViewLabelElement;
        if (label != null)
        {
            Console.WriteLine(label.Text);
        }
    }
    e.CanDrop = true;
}

Can you test this code in your application? If it is still not working, can you modify my test project and include all the controls which are currently present in the document window content area?

Tags
Dock Treeview
Asked by
Hayley
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or