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
close icon

Drap and Drop in Virtual Cells

Hi, I am using virtual cells in the GridContol. When I drag a virtual cell from one grid and drop into another grid the value in the source grid is lost also in the destination grid. The same behavior is happened while dragging an ordinary cell and drop into virtual cell. Herewith I have attached a sample program to show the problem. Kindly let me know how to solve the problem. Thanks, Suresh Mani. GridDragDrop_1097.zip

3 Replies

AD Administrator Syncfusion Team September 15, 2004 09:57 AM UTC

The default behavior of a OLE D&D is to do a move, and not a copy. This will clear the data from the source of the drop. If you want a copy instead of a move, the convention is to hold down teh control key when you do the drop. If you do hold down the control key as you drop, the information in the source should not be affected. If you want to change this default behavior, one way is to derive the GridControl and override OnDragDrop. In the override, after calling the baseclass, set e.Effects to Copy.
public class MyGridControl : GridControl
	protected override void OnDragDrop(DragEventArgs drgevent)
		base.OnDragDrop (drgevent);
		drgevent.Effect = DragDropEffects.Copy;

SM Suresh Mani September 16, 2004 08:11 AM UTC

Hi Clay Burch, The solution solves the problem for loosing data in the source cell. But still the virtual cell problem is existed. Here I attached sample program to show the problem. 1. Run the application. 2. Drag virtual cell data from one grid into another grid virtual cell. Now you can see that the dragged data not appeared in the cell, also while dropping the virtual cell mode is disappeared. Kindly let me know how to solve the problem. Thanks Suresh Mani. DragDropInVirtualCell_379.zip

AD Administrator Syncfusion Team September 16, 2004 09:10 AM UTC

The sample you attached does not use a virtual grid. It stores data in the GridData object using indexers on the grid. With that sample, I do not see a problem with D&D. Here is the picture of what I see after running the sample, selecting cells on the left grid and dragging them to the right grid. dndgrid_5020.zip By default, a grid supports dragging both styles and text formats. In a virtual grid, there are no style formats available for the drag as no style information is stored by the grid. So, in a virtual grid, you can tell the grid to only try to use the Text format by removing the styles flag from the DragDropTargetFlags: gridControl1.Model.Options.DragDropDropTargetFlags &= ~GridDragDropFlags.Styles;

Live Chat Icon For mobile
Up arrow icon