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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Drag and drop between grids

Thread ID:





11342 Mar 3,2004 07:42 AM UTC Mar 4,2004 11:45 AM UTC WinForms 1
Tags: GridControl
Gerhard Häring
Asked On March 3, 2004 07:42 AM UTC

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.

Administrator [Syncfusion]
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon