We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

drag node and drop on another node

Thread ID:

Created:

Updated:

Platform:

Replies:

65640 Jul 26,2007 10:50 PM UTC Jul 27,2007 03:17 PM UTC WinForms 3
loading
Tags: Diagram
Giancarlo Aguilera
Asked On July 26, 2007 10:50 PM UTC

Hi!

I have another question I am hoping someone can answer.

I have a diagram like the one shown in the attachment. Each node in the diagram is a controlnode that hosts a usercontrol. What I need to do is allow the user to drag one node and drop it on another node and take some action when the drop happens. Could you please give me some hints on how to go about doing this? I've been looking in the forums but most drag and drop involes dragging & dropping from palette to diagram. I don't want that. Rather I need to drag a node and drop it on some other node and take some kind of action when the drop happens.

Thanks much for your help

GA

Doc123.zip

J.Nagarajan [Syncfusion]
Replied On July 27, 2007 01:18 AM UTC

Hi GA,

If you want to fire a event when you drag and drop a node on the existing node then you can write a delegate. Please refer to the following code snippet

public delegate void NodeDragDrop(object sender, EventArgs e);
public event NodeDragDrop nodedragdrop;

public Form1()
{
InitializeComponent();
this.nodedragdrop += new NodeDragDrop(Form1_nodedragdrop);
}
private void diagram1_DragDrop(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(typeof(TreeNode)))
{
TreeNode treenode = (TreeNode) e.Data.GetData(typeof(TreeNode));
TextNode textnode = new TextNode(treenode.Text);
textnode.SizeToText(new SizeF(0,0));
textnode.PinPoint = pt;
this.diagram1.Model.AppendChild(textnode);
this.diagram1.Refresh();

if (symbol2.BoundingRectangle.IntersectsWith(textnode.BoundingRectangle))
{
this.nodedragdrop(sender, e);
}
}
}

I have attached the sample that demonstrates this completely. You can download the sample from the following page.

http://websamples.syncfusion.com/samples/Diagram.Windows/F65640/main.htm

Please let me know if you have any questions.

Thanks,
Nagaraj


Giancarlo Aguilera
Replied On July 27, 2007 12:46 PM UTC

Hi,

Thanks for the response.

Your sample is great but it does not illustrate what I need to do. Your sample illustrates dragging a node from one of the controls located OUTSIDE the diagram and then dropping it onto an existing node already on the diagram. What I am looking to do is a bit different. I need to be able to drag a node ALREADY LOCATED on the diagram and drop it on another node that is also ALREADY located on the diagram. For example, say I have a diagram with 2 nodes on it, node A and node B. I need to be able to drag node A and drop it on node B.

Any ideas?

J.Nagarajan [Syncfusion]
Replied On July 27, 2007 03:17 PM UTC

Hi GA,

Thanks for the details. If you want to fire an event when you drag drop a node on the existing node, then you have to write a delegate to fire this event. Please refer to the following code snippet.

//Declare the delegate for NodeDragDrop event
public delegate void NodeDragDrop(object sender, EventArgs evtargs);
//Declare the NodeDragDrop event
public event NodeDragDrop nodedragdrop;

public MainForm()
{
InitializeComponent();
this.nodedragdrop += new NodeDragDrop(MainForm_nodedragdrop);
}

private void diagram1_MouseUp(object sender, MouseEventArgs e)
{
if (this.diagram1.Controller.SelectionList.Count > 0)
{
if(rect.BoundingRectangle.IntersectsWith(symbol2.BoundingRectangle))
{
//Fire Node DragDrop
this.nodedragdrop(sender,new EventArgs());
}
}
}

I have attached the sample that demonstrates this completely. You can download the sample from the following page.

http://websamples.syncfusion.com/samples/Diagram.Windows/DragAndDrop/main.htm

I hope this will meet your requirement. Please let me know if you have any questions.

Thanks,
Nagaraj

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;