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

Dragging/Moving a RadDiagramShape on RadDiagram

3 Answers 474 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Karandeep Singh
Top achievements
Rank 1
Karandeep Singh asked on 13 Aug 2012, 09:32 PM
I have been creating and adding RadDiagramShape to the RadDiagram control at run time.
I wan to detect/capture the event whenever the shape is moved(dragged to change its position) on the RadDiagram control.
How can I do that?

I tried to do something like 
radShape.DragEnter += OnShapePositionChanged;


also tried
radShape.AddHandler(RadDragAndDropManager.DragQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnShapePositionChanged));

Didn't work.
Help

3 Answers, 1 is accepted

Sort by
0
Accepted
Miro Miroslavov
Telerik team
answered on 14 Aug 2012, 06:17 AM
Hi Karandeep Singh,

 You can handle the RadDiagram.PreviewDrag event as well as the RadDiagram.DragEvent. The first one occurs right after the drag has started (you can also handle it and stop the drag), while the second event is raised the drag has ended (the mouse is released).
Please let us know if these events work for you. 

Kind regards,
Miro Miroslavov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Thiruvengadam
Top achievements
Rank 1
answered on 11 Sep 2015, 12:09 PM

How can I access the below using the DragEvent.

 1.  The Item that is Dropped.

2. The Item within which the Item is Dropped.

 for (e.g) If I am dropping a shape "Fruit" inside a container "Basket", how do I get the "Fruit" and "Basket"?

0
Milena
Telerik team
answered on 16 Sep 2015, 08:43 AM
Hello Thiruvengadam,

As my colleague Peter explained you in another thread -  container shapes (the "Basket" I suppose) only visually contains other shapes / containers. The child shapes reside in the Children collection of the ContainerShape, but their parent is actually the Diagram. However, if you need to detect when a shape ("Fruit") is dropped in Container Shape ("Basket") - you can inherit the RadDiagramContainerShape class and override the OnItemsCollectionChanged event:
public class CustomContainerShape : RadDiagramContainerShape
{
    protected override void OnItemsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
    {
        base.OnItemsCollectionChanged(sender, e);
    }
}

You can get the item/s which is/are dropped inside the container from event arguments - e.NewItems collection.

I hope this information helps.

Regards,
Milena
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
Tags
Diagram
Asked by
Karandeep Singh
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Thiruvengadam
Top achievements
Rank 1
Milena
Telerik team
Share this question
or