RadDragAndDropManager is that missing.

2 posts, 0 answers
  1. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 04 May 2015 Link to this post

    I was looking for example on how to disable auto scrolling when trying to do drag and drop. I find that you can do so with  RadDragAndDropManager, so i start looking for it in winform version and i was not able to find that class at all. Is there a way to disable automatically scrolling of a RadListView when dragging from the listview to something else.
  2. Dess
    Admin
    Dess avatar
    1608 posts

    Posted 07 May 2015 Link to this post

    Hello Hugues,

    Thank you for writing.

    I suppose that you need ListViewDragDropService. In its HandleMouseMove method, the service performs scrolling when the mouse is outside the view. You can create a derivative of the ListViewDragDropService and override the mentioned method where you can perform the desired drag and drop functionality without scrolling. You can refer to our ListView >> Drag and Drop section in the online documentation which demonstrates how to customize the drag and drop behavior. Additionally, I have prepared a sample code snippet demonstrating how to modify the service in order to disable scrolling:
    public Form1()
    {
        InitializeComponent();
        new RadControlSpyForm().Show();
     
        for (int i = 0; i < 20; i++)
        {
            this.radListView1.Items.Add("Item" + i);
        }
     
        this.radListView1.AllowDragDrop = true;
     
        this.radListView1.AllowArbitraryItemHeight = false;
        this.radListView1.ItemSize = new Size(100, 40);
        this.radListView1.ListViewElement.DragDropService = new CustomListViewDragDropService(this.radListView1.ListViewElement);
    }
     
    public class CustomListViewDragDropService : ListViewDragDropService
    {
        public CustomListViewDragDropService(RadListViewElement owner) : base(owner)
        {
        }
     
        protected override void HandleMouseMove(Point mousePos)
        {
            FieldInfo initializedField = typeof(RadDragDropService).GetField("initialized", BindingFlags.Instance | BindingFlags.NonPublic);
            
            if (!this.Initialized && ShouldBeginDrag(this.beginPoint.Value, mousePos))
            {
                initializedField.SetValue(this, this.PrepareContext());
            }
     
            if (!this.Initialized)
            {
                return;
            }
     
            MethodInfo mi = typeof(RadDragDropService).GetMethod("DoDrag", BindingFlags.NonPublic | BindingFlags.Instance) ;
            mi.Invoke(this, new object[] { mousePos });
            this.beginPoint = mousePos;
         
            FieldInfo fi = typeof(ListViewDragDropService).GetField("dragHintWindow", BindingFlags.NonPublic | BindingFlags.Instance);
            RadLayeredWindow dragHintWindow = fi.GetValue(this) as RadLayeredWindow;
            if (dragHintWindow == null && this.CanCommit)
            {
                this.PrepareDragHint();
            }
     
            this.UpdateDragHintLocation(mousePos);
        }
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top