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

Detect drop from toolbox

2 Answers 54 Views
Diagram, DiagramRibbonBar, DiagramToolBox
This is a migrated thread and some comments may be shown as answers.
Valentino
Top achievements
Rank 1
Valentino asked on 25 Aug 2017, 04:52 AM
What is the best way to react to a shape being drag-dropped onto the diagram from the toolbox? At the moment I'm subscribing to the ItemsChanged event but I'm sure there must be a better way? I'm also doing things with drag-drop (shapes within the diagram) but this doesn't seem to relate to the toolbox.

2 Answers, 1 is accepted

Sort by
0
Tino
Top achievements
Rank 1
answered on 01 Sep 2017, 03:15 AM

ok, I had seen DragDropService_PreviewDragDrop earlier but somehow forgot about it.

Anyway, I've implemented it but mu dropTarget.Shapes collection is always empty.. Why would that be.

I'll probably lodge a ticket now that I have been assigned a login.

0
Dimitar
Telerik team
answered on 04 Sep 2017, 06:35 AM
Hello Valentino,

You can use the following code to get the diagram in the PreviewDragDrop event handler:
public RadForm1()
{
    InitializeComponent();
 
    radDiagramToolbox1.ListViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop;
}
void DragDropService_PreviewDragDrop(object sender, Telerik.WinControls.RadDropEventArgs e)
{
    var diagramElement = e.HitTarget as RadDiagramElement;
    if (diagramElement != null)
    {
        Console.WriteLine(diagramElement.Items.Count);
    }
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Diagram, DiagramRibbonBar, DiagramToolBox
Asked by
Valentino
Top achievements
Rank 1
Answers by
Tino
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or