*Experts* DiverDan Posted April 28, 2006 *Experts* Posted April 28, 2006 Hi, I'm having a problem programmably increasing a panel's AutoScrollPosition. With the lower code, the auto scroll vibrates up and down instead of progressing constantly downward. Private Sub bkrTemp_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bkrTemp.MouseMove Dim pt As Point pt.X = Me.PointToClient(Cursor.Current.Position).X - x pt.Y = Me.PointToClient(Cursor.Current.Position).Y - y With bkrTemp .Location = pt .Capture = True End With If pnlPanel.AutoScroll = True Then Dim bkrLocY As Integer = bkrTemp.Location.Y - (pnlPanel.Location.Y + pnlPanel.AutoScrollPosition.Y) + bkrTemp.Height Dim pnlHeight As Integer = pnlPanel.Height - (pnlPanel.AutoScrollMargin.Height + 17) If bkrLocY + 2 >= pnlHeight Then pnlPanel.AutoScrollPosition = New Point(pnlPanel.AutoScrollPosition.X, pnlPanel.AutoScrollPosition.Y + 5) End If End If End Sub How can I have pnlPanel scroll constantly downward with bkrTemp? Thanks, Dan Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Leaders snarfblam Posted April 28, 2006 Leaders Posted April 28, 2006 I ran into a very similar problem recently. The AutoScrollPosition property is pretty quirky. When you get the AutoScrollPosition is returns how much the view has moved, i.e. {10, 20} would be scrolled right ten and down twenty. When you set it, you need to specify how far the controls should be moved. If you are scrolled ten right and twenty down, the controls have moved ten left and twenty up on the screen, which means that you would want to set AutoScrollPosition to {-10, -20} to set it to that same position. I'm guessing that this is a bug. I believe that the solution is to negate the value immediately before assigning it (if you want to think in terms of where the view port is... if you want to think in terms of how far the controls have moved, negate the value as soon as you obtain it). For example, to move the AutoScrollPosition down and right fifty pixels, you would use the following code: Dim View As Point = MyPanel.AutoScrollPosition View.X = -(View.X + 50) View.Y = -(View.Y + 50) MyPanel.AutoScrollPosition = View I didn't test that code, but something like that should do the trick. Quote [sIGPIC]e[/sIGPIC]
*Experts* DiverDan Posted April 29, 2006 Author *Experts* Posted April 29, 2006 Thanks Marble Eater, With your help I got it working perfectly. Thanks again, Dan Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.