Completed
Last Updated: 26 Nov 2018 15:42 by Dimitar
ADMIN
Hristo
Created on: 22 Nov 2018 07:26
Category:
Type: Bug Report
1
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
How to reproduce: check the attached video

Workaround: create a custom drag-drop service
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;
        }
    }
}

Attached Files:
0 comments