How do I implement drag-scroll as is done in Excel and Word?

I have a panel control that contains multiple copies of a user control I created. The panel control automatically displays scrollbars when there are too many user controls to fit in its display area. This is correct behavior.

I have implemented drag-drop of data between the user controls. This works correctly. However, when I need to drag from one to the other and the target user control is not visible, I need the panel control to automatically begin scrolling when the mouse is moved out of the panel during the drag operation so that the hidden control will scroll into view. This is the same as is done in Excel or Word when a user drags information outside the boundaries of the document.

I could probably use the panel's ScrollControlIntoView method, but for some reason, this does not work. No matter how much I have played with it, I get no autoscrolling to the control that should be visible.

Thanks in advance!

[964 byte] By [coder54] at [2008-1-4]
# 1

Hello,

Based on your question , I recommend you may do the following steps:

1 Panel control has the HorizontalScroll.Value and VerticalScroll.Value property. We can set the value to make the panel control scroll . I write the simple program . It can scroll the panel by handling the Form MouseMove Event .

2 In your drag-drop program , you can handle the MouseEvent of drag source object . There are the X ordination and Y ordination In the MouseEventArgs . Then you can set the HorizontalScroll.Value and VerticalScroll.Value . This will make the panel scroll.

Hope this can give your help !

Riquel

RiquelDong–MSFT at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2

Try this, it worked for me when I needed to do it with pictureboxes.

Private Sub PictureBox1_QueryContinueDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles PictureBox1.QueryContinueDrag

OnErrorResumeNext

If Control.MousePosition.Y < Me.DesktopBounds.Top Then

Me.VerticalScroll.Value = Me.VerticalScroll.Value - 100

IfMe.VerticalScroll.Value < 100 ThenMe.VerticalScroll.Value = 0

ElseIf Control.MousePosition.Y > Me.DesktopBounds.Bottom Then

Me.VerticalScroll.Value = Me.VerticalScroll.Value + 100

EndIf

Rykler at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...