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.
Unfortunately, activation email could not send to your email. Please try again.

Dragging rows to another control

Thread ID:

Created:

Updated:

Platform:

Replies:

17915 Aug 19,2004 08:48 AM Aug 24,2004 08:37 AM Windows Forms 8
loading
Tags: GridControl
Doug Lind
Asked On August 19, 2004 08:48 AM

Hello, I have an application that needs to support dragging rows within a GDBG and onto another control. Row dragging within the grid was no problem, but I''m having difficulty with getting them to another control. The internal row drag handler doesn''t seem to know when it leaves the grid or form. It just tracks mouse position relative to the row headers. Do I need to implement a replacement row drag handler to implement dragging within and off the grid? If so, are there hooks so I still have the insert bar displayed as the cursor is dragged within the grid? Thanks, Doug

Administrator [Syncfusion]
Replied On August 19, 2004 09:59 AM

There are two type of drag operations in the grid with respect to rows. One is moving a row to a new location in the grid. This row moving is controlled by the AllowDragSelectedRows property and is off by default in a GridDataBoundGrid. Using this functionality will only drag rows within the same grid to move them within the grid, and is only really supported in a GridControl that holds its own data. In a GridControl, you would select a row or several rows by dragging the row headers, and then mousedown on one of the selected headers to drag the rows to a new position. You can turn on the UI behavior in a GridDataBoundGrid, but it will not actually move the rows for you. The second drag functionality is OLE D&D. This is supported in a GridDataBoundGrid and a GridControl. If you select several rows, and then place the cursor at the border of the selection, you should get a drag cursor that starts a OLE D&D. If you have set grid.AllowDrop = false, you should get the nodrop cursor while you are over the grid. Then if you move over other controls that have AllowDrop = true set, and accept a Text drop, you should be able to drop the rows. The data will be tab delimited text for columns and newline delimited rows. If you want to use a custom data object as part of the drop data, you can do so using the grid1.Model.QueryOleDataSourceData event to put your own custom object into the data object being used by the OLE D&D. So, if you can use the default OLE D&D support, that would be the simplest way to enable dragging rows to another control.

Doug Lind
Replied On August 19, 2004 11:46 AM

Thanks for the quick response Clay. I tried using the 2nd (default) method but do not get the drag icon when hovering over the selected rows. I have enabled the grid set as an OLE source and have .AllowDrop = True Is there something else I need to set to get the row drag cursor to show or should I be handling it all in code? Doug

Administrator [Syncfusion]
Replied On August 19, 2004 11:56 AM

No, you should only have to drag a GridDataBoundGrid onto a form, and populate it with a datasource. The OLE D&D is turned on by default. If you then select several rows, and then move the cursor to the bottom of the selection, you should see a drop cursor appear. When this cursor is present, you should be able to mousedown and drag the rows to, say Excel. In this forum thread, http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=17811, there is a little sample at the bottom, that is more or less a default grid. That sample works for me as I described above. Does it work for you?

Doug Lind
Replied On August 19, 2004 12:15 PM

OK I see that it does work. I was expecting behavior like with column drags, where the cursor changes whereever you are in the column header. Thanks for the support ;-) Doug

Doug Lind
Replied On August 24, 2004 07:17 AM

One more question... In your previous replies you mentioned using grid1.Model.QueryOleDataSourceData event to create custom data. When I try to create a handler for the event in a GridDataBoundGrid, the event is not available. Can you post a snippet showing how the handler is declared for a GDBG? Below is what I was trying: Private Sub gdbgOrders_QueryOleDataSourcedata(ByVal sender As Object, ByVal e As GridQueryOleDataSourceDataEventArgs) Handles gdbgOrders.QueryOleDataSourceData End Sub Thanks, Doug

Administrator [Syncfusion]
Replied On August 24, 2004 07:26 AM

It is a member of the grid.Model object and not the grid. So, to subscribe to the event, try code like: AddHandler gdbgOrders.Model.QueryOleDataSourcedata, addressof gdbgOrders_QueryOleDataSourcedata

Doug Lind
Replied On August 24, 2004 07:37 AM

Thanks!

Doug Lind
Replied On August 24, 2004 08:37 AM

Clay, I''m having an issue with the GDBG wanting to move the rows itself and messing up the row layout. I want to handle the actual move myself in the DataSource. Is there a way to disable the internal row moving? I tried disabling the DragDropDropTargetFlags but that just made the drag box go away, and the rows were still moved. Doug

CONFIRMATION

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.

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.

;