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

Drag and drop between grids

I have a virtual grid and the user needs to be able to change the position of the rows within the grid. This works fine by implementnig the RowsMoved event. But I also need to be able to drag and drop rows between two grids. The row then needs to disappear in the source grid and needs to be put in the destination grid. Ideally with the ability to exactly place the row using the neat cursor *between* existing rows. I. e. place the dragged row between row 3 and 4 or something. How would I best develop this feature? I''d be most grateful if you could show me example code. TIA.

1 Reply

AD Administrator Syncfusion Team March 4, 2004 11:45 AM UTC

It order to be able to do this, your external datasources for your 2 virtual grids must support inserting/removing rows. Below is a rough try at this. Since you want special behavior (deleting from the source and inserting into the target along with special drawing queues), and since these are virtual grids where the grid odes not manage the data, the sample uses a derived grid and interacts with the virtual Control methods like OnDragEnter, OnDragDrop, etc, to implement the requested behavior with custom visual queues being drawn as you drag. There are other options of implementing your own custom data objects that can be used directly in teh grid''s own OLE support. This requires creating a IGridDataObjectConsumer object and using RegisterDataObjectConsumer to register it, but this would not let you immedaitely get access to drawing custom visual queues which would require additional work. Now the derived grid in the sample does fire events, so you probably customize through listening to these events from, say, the parent form. But, in the sample, the customization code is down in the overrides. The idea is to create an array list of ''row objects'', and then use this as the drag data. The sample has a VirtDataSource class derived from ArrayList that allows the inserting/removing of ''row objects''. It also have various indexers defined to allow straight forward access to the row objects in the arraylist (and to the objects that are in each row object). Maybe this will serve a starting point for your implementation. forum11342_3705.zip

Loader.
Live Chat Icon For mobile
Up arrow icon