Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
UltraListView Drag, Drop & SCROLL
posted

I have a list view with all the d&d stuff implimented (excellent sample btw) where it drags and drops onto itself to allow for image re-ordering (in THUMBNAIL mode) - which all works fine- until I need to drag up or down out of the current client rectangle.  I've tried using ScrollControl but have not had much success.  I'm sure I'm doing something wrong; would it be possible to get a sample of how to use ScrollControl (or equivelent) with the OnDragOver() event to scroll the list view up or down so other items can come into view?  Thanks!

 Here's what I've tried so far with little success (it scrolls up choppily, doesn't repaint, and then jumps back):

        protected override void OnDragOver(DragEventArgs drgevent)
        {
            Point clientPoint = PointToClient(new Point(drgevent.X, drgevent.Y));
            UltraListViewItem hoverItem = ItemFromPoint(clientPoint);
            if(hoverItem == null)
            {
                drgevent.Effect = DragDropEffects.None;
                return;
            }
            if(clientPoint.Y <= 10)
            {
                Rectangle updateRect = new Rectangle();
                Rectangle scrollRect = new Rectangle(ClientRectangle.X, ClientRectangle.Y + 10, ClientRectangle.Width, ClientRectangle.Height);
                this.ScrollControl(0, 10, scrollRect, ClientRectangle, ref updateRect, true, true, false, 10);
            }
            base.OnDragOver(drgevent);
        }
     

Parents
No Data
Reply
  • 69832
    Offline posted

     ScrollControl not intended to be used externally; it is essentially a wrapper for the ScrollWindowEx Windows API. You should not use it for this.

    UltraListView implements the ISelectionManager interface, which happens to expose a method called DoDragScrollVertical. You can use this for the purpose you described here; you could do something like compare the cursor position to what it was the last time OnDragOver was called and also check to see if the cursor is positioned in the top or bottom area of the control, then call the DoDragScrollVertical method if the cursor has hovered within that area for a given period of time. Note that UltraListView's DoDragScrollVertical implementation does not make use of the 'timerInterval' parameter, and it will only work correctly when the cursor is positioned within the top or bottom 16 pixels of the control...it is stable but is not really part of the public object model so you are constrained by those caviats.

     Example:

    ISelectionManager selectionManager = this.ultraListView1 as ISelectionManager;
    selectionManager.DoDragScrollVertical( 1 );

Children
No Data