DragDrop from one Listview to another and let the receiving scroll

3 posts, 1 answers
  1. Patrick
    Patrick avatar
    43 posts
    Member since:
    Aug 2018

    Posted 21 Nov 2018 Link to this post

    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. Answer
    Hristo
    Admin
    Hristo avatar
    1520 posts

    Posted 22 Nov 2018 Link to this post

    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.
  3. Patrick
    Patrick avatar
    43 posts
    Member since:
    Aug 2018

    Posted 23 Nov 2018 in reply to Hristo Link to this post

    Hi Hristo,

    Thanks for your solution.

    Regards

    Patrick Vossen

Back to Top