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. Image for the cookie policy date

Drag/Drop to Grid from external source

I am trying to drop an object onto a Grid Control. I set up the drag/drop operation in Form1 of an MDI app like this: private void songListView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { String s="Testing..."; songListView.DoDragDrop(s.ID.ToString(), DragDropEffects.Copy); } Form2 includes the following: gridControl1.AllowDrop = true; gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Text; private void gridControl1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if(e.Data.GetDataPresent(DataFormats.Text, true)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } I verified that the DragEnter handler IS being called correctly. However, my mouse cursor never changes to the "Allow Drop" mode anf gridControl1_DragDrop() does not get called when I drop. Any Ideas???

2 Replies

AD Administrator Syncfusion Team August 4, 2003 08:30 PM UTC

Try this. It creates a DataObject and sets the DataFormats.Text datatype so it could be tested in the grid. It also specifies DragDropEffects.All so you do not have to press the shift to do the drop. Since the source is responsible for deleting the moved object, it will not do any harm to accept all actions in the grid.
private void Form1_MouseDown(object sender, MouseEventArgs e)
	String s = "Testing...";
	DataObject data = new DataObject(DataFormats.Text, s);
	this.DoDragDrop(data, DragDropEffects.All);

BA Blaine Anderson August 4, 2003 10:31 PM UTC

Thanks!! That works!

Live Chat Icon For mobile
Up arrow icon