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

DragDrop from one Listview to another and let the receiving scroll

2 Answers 180 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 21 Nov 2018, 12:47 PM

Hello,

I've got two RadListViews with dragdrop functionality enabled (using DragDropService).

Both Listviews have more items in the list (vertical scrollbar enabled)

When I want to drag one item from the source Listview to the target Listview, and dragging the item to the upper/lower bound of the target Listview, the source listview starts scrolling instead of the target listview (see this movie).

Is it possible (and if possible, how can I accomplish) to NOT scroll the source listview but DO scroll the target listview?

Best regards

Patrick Vossen

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 22 Nov 2018, 07:39 AM
Hi Patrick,

The observed behavior can be considered an issue and I have logged it on our feedback portal, here:
FIX. RadListView - dragging an item from one list view to another can result in incorrect scrolling of the source list view when it is not necessary. I have also updated your Telerik points. We will do our best to include the fix of the issue in the R1 2019 release. A possible workaround is to use the custom drag-drop service below: 
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
    public RadForm1()
    {
        InitializeComponent();
        this.radListView1.AllowDragDrop = true;
        this.radListView2.AllowDragDrop = true;
 
        this.radListView1.ListViewElement.DragDropService = new CustomListViewDragDropService(this.radListView1.ListViewElement);
        this.radListView2.ListViewElement.DragDropService = new CustomListViewDragDropService(this.radListView2.ListViewElement);
    }
}
 
public class CustomListViewDragDropService : ListViewDragDropService
{
    public CustomListViewDragDropService(RadListViewElement owner)
        : base(owner)
    { }
 
    protected override void HandleMouseMove(Point mousePos)
    {
        int? scroll = null;
        SimpleListViewVisualItem item = this.DropTarget as SimpleListViewVisualItem;
        if (item != null && item.Data.Owner != this.Owner)
        {
            scroll = this.Owner.ViewElement.VScrollBar.Value;
            Point clientPos = item.Data.Owner.ViewElement.PointFromScreen(mousePos);
 
            if ((clientPos.Y < 0 && item.Data.Owner.ViewElement.Orientation == Orientation.Vertical) ||
                (clientPos.X < 0 && item.Data.Owner.ViewElement.Orientation == Orientation.Horizontal))
            {
                item.Data.Owner.ViewElement.Scroller.Scrollbar.PerformSmallDecrement(1);
            }
            else if ((clientPos.Y > item.Data.Owner.Size.Height && item.Data.Owner.ViewElement.Orientation == Orientation.Vertical) ||
                (clientPos.X > item.Data.Owner.Size.Width && item.Data.Owner.ViewElement.Orientation == Orientation.Horizontal))
            {
                item.Data.Owner.ViewElement.Scroller.Scrollbar.PerformSmallIncrement(1);
            }
        }
 
        base.HandleMouseMove(mousePos);
 
        if (scroll.HasValue)
        {
            this.Owner.ViewElement.VScrollBar.Value = (int)scroll;
        }
    }
}

I hope this helps. Let me know if you need further assistance.

Regards,
Hristo
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.
0
Patrick
Top achievements
Rank 1
answered on 23 Nov 2018, 11:29 AM

Hi Hristo,

Thanks for your solution.

Regards

Patrick Vossen

Tags
ListView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or