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

Cancelling a Drop operation in GDBG

Users sometimes need to move the content from one GDBG cell to another cell, but the application asks the user to confirm this is what he wants to do before carrying out the move. I use the drag-drop features of GDBG by handling the DragDrop event. In the event handler I have the code ask the user if he wants to do the move. Carrying out the move (modifying the underlying data source content) works fine if he says yes. But if he says no, although the underlying data is not moved, the visible cell rendered in the grid appears to have moved. Is there a way to cancel the drop, restoring the grid back to the original appearance before the drag-drop event? I''ve tried setting e.Effect = DragDrofEffects.None in the DragDrop event handler but this seems to have no effect. For performance reasons, I wanted to avoid refreshing the entire grid if possible. Thanks, Van Baker

1 Reply

AD Administrator Syncfusion Team June 27, 2005 08:26 AM UTC

I was able to do this by deriving the GridDataBoundGrid and Effect = None before calling the baseclass in OnDragDrop. Trying to use events, you cannot control the order of the handlers. You need to set the Effect = None before any handlers get a chance to operate on the data. The only way I know to do this is to use a derived grid.
public class MyGridDataBoundGrid : GridDataBoundGrid
	protected override void OnDragDrop(DragEventArgs drgevent)
		if(MessageBox.Show("DropData?", "", MessageBoxButtons.YesNo) == DialogResult.No)
			drgevent.Effect = DragDropEffects.None;
		base.OnDragDrop (drgevent);

Live Chat Icon For mobile
Up arrow icon