Detect drop from toolbox

3 posts, 0 answers
  1. Valentino
    Valentino avatar
    28 posts
    Member since:
    Aug 2017

    Posted 24 Aug 2017 Link to this post

    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. Tino
    Tino avatar
    86 posts
    Member since:
    Jul 2017

    Posted 31 Aug 2017 in reply to Valentino Link to this post

    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.

  3. Dimitar
    Admin
    Dimitar avatar
    2907 posts

    Posted 04 Sep 2017 Link to this post

    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.
Back to Top