Nevron Forum

How to TreeView Node Drag in NDrawingView Drop?

https://www.nevron.com/Forum/Topic6841.aspx

By Park yunsin - Friday, August 17, 2012

Hi

How to TreeView Node Drag in NDrawingView Drop?

Failed to create drag drop data preview. Exception was: Null Refrence Error

Mouse Cursor ICon is None

Help Me

By Nevron Support - Friday, August 17, 2012

Take a look at the Drawing View -> Custom Drag and Drop Example that comes with Nevron Diagram for .NET.
By David Dieffenthaler 1 - Monday, January 27, 2014

Nevron Support Team,

I think that the Custom Drag and Drop Example is fine but not very practical for my scenario, I would like to create new NShape when something is dropped in the NDrawingView rather than creating NSHape first and attach them to the .Tag as NMyDataObject

So is there a way to override the DragDrop event?

I tried to to this in the code but it only works on the edges

private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
int index = listBox1.IndexFromPoint(e.X, e.Y);
object s = null;
if (index >= 0)
s = listBox1.Items[index];
if (s != null)
listBox1.DoDragDrop(s, DragDropEffects.Copy);
}
private void nDrawingView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}

private void nDrawingView1_DragDrop(object sender, DragEventArgs e)
{
MessageBox.Show("Drop");
}

Result is I can drag and drop in the ruler bars, but I can't drop in the main view area, see attached screenshot (I added the cursors later on the image to reflect how the cursor changes in different areas of the NDrawingView)

My question can be resumed at: Can we override the DragDrop method of the NDrawingView somwhow instead of relying only in the built in features of the control?

Thanks
By Nevron Support - Monday, January 27, 2014

You can override the OnDragEnter, OnDragOver, OnDragDrop and OnDragLeave of the NDrawingView and perform custom drag and drop if you want.

However note that you will loose many build in features like drag and drop ghost, auto-scrolling during drag and drop etc.