This is a migrated thread and some comments may be shown as answers.

Auto Scrolling When Performing Drag and Drop between GridViews

1 Answer 866 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 02 Jan 2020, 03:42 AM

I've implemented drag and drop between two RadGridViews using RadGridViewDragDropService.

This works well, but I can't get Auto Scrolling to work when dragging from one gridview to another. It does work if I drag within the same gridview.

I do have AllowAutoScrollRowsWhileDragging set to true.

What could I be doing wrong?

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Jan 2020, 12:02 PM
Hello, Joe,   
  
I am not sure what is the exact drag and drop implementation that you have on your end, but I would recommend you to have a look at the following help articles which are quite useful on this topic:
https://docs.telerik.com/devtools/winforms/controls/gridview/drag-and-drop/radgridviewdragdropservice 
https://docs.telerik.com/devtools/winforms/controls/gridview/rows/drag-and-drop 

Auto-scroll behavior while dragging is relevant only when the source and target controls are the same. If you drag from one RadGridView and drop the row to another RadGridView, the auto-scrolling behavior is not expected to be executed. 

However, you can disable the AllowAutoScrollRowsWhileDragging property for the RadGridViewDragDropService and perform the scrolling for the target grid programmatically. In the PreviewDragOver event you can check the HitTarget and increase the GridViewElement.TableElement.VScrollBar.Value of the target grid: 
        private void svc_PreviewDragOver(object sender, RadDragOverEventArgs e)
        {
            if (e.DragInstance is GridDataRowElement)
            {
                e.CanDrop = e.HitTarget is GridDataRowElement ||
                            e.HitTarget is GridTableElement ||
                            e.HitTarget is GridSummaryRowElement;
            }
            if (e.CanDrop = true)
            {
                GridDataRowElement hitTarget = e.HitTarget as GridDataRowElement;
                if (hitTarget != null && hitTarget.TableElement.VisualRows.Last() == hitTarget)
                {
                    hitTarget.GridViewElement.TableElement.VScrollBar.Value = Math.Min(hitTarget.GridViewElement.TableElement.VScrollBar.Maximum,
                        hitTarget.GridViewElement.TableElement.VScrollBar.Value + hitTarget.GridViewElement.TableElement.VScrollBar.SmallChange - 1);
                }
            }
        }

Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your requirements best.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tibor
Top achievements
Rank 1
Iron
Iron
commented on 06 May 2024, 06:46 AM

AllowAutoScrollRowsWhileDragging was the property I so desperately needed. Amazing job, thanks a lot from the future!
Tags
GridView
Asked by
Joe
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or