GroupView drag and drop

I need to be able to support dragging and dropping an item in a GroupView onto another control. Both examples in the documentation appear to demostrate how you would drop something on a GroupView rather than dragging something from the GroupView.

Specifically, I can't figure out how to initiate the drag within the GroupView. For a TreeView I would simply trap the ItemDrag event. For a ListBox I would trap the MouseDown event and use the IndexFromPoint(e.X, e.Y) method to determine which item was being dragged.

How do I initiate the drag for a GroupViewItem?


1 Reply

MJ Mano J Syncfusion Team August 10, 2009 07:08 AM UTC

Hi Scott,

Please check the code snippet below to drag a GroupViewItem and drop into a TreeView.


this.groupView1.AllowDragDrop = true;
this.treeView1.AllowDrop = true;

private void treeView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}

private void treeView1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("GroupViewItemDataFormat"))
{
object data = e.Data.GetData("GroupViewItemDataFormat");
if (data != null)
{
treeView1.Nodes.Add(((GroupViewItem)data).Text);
}
}
}


Please let me know if you have any questions.

Best Regards,
Mano

Loader.
Up arrow icon