Why does the scrollbar only work when the control moves out of view on the RIGHT of the panel but not on the LEFT?
Just make a windows forms application in VB, and paste the following code into the code window of Form1. (The code includes the designer code so all controls get created properly.)
Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub btnMoveLeft_Click(sender As System.Object, e As System.EventArgs) Handles btnMoveLeft.Click
TextBox1.Left -= 10
End Sub
Private Sub btnMoveRight_Click(sender As System.Object, e As System.EventArgs) Handles btnMoveRight.Click
TextBox1.Left += 10
End Sub
Private Sub btnBigger_Click(sender As System.Object, e As System.EventArgs) Handles btnBigger.Click
TextBox1.Width += 10
End Sub
Private Sub btnSmaller_Click(sender As System.Object, e As System.EventArgs) Handles btnSmaller.Click
If TextBox1.Width > 10 Then TextBox1.Width -= 10
End Sub
#Region "Designer items"
Private components As System.ComponentModel.IContainer
Private Sub InitializeComponent()
Me.pnlAutoScrollTest = New System.Windows.Forms.Panel()
Me.btnMoveLeft = New System.Windows.Forms.Button()
Me.btnMoveRight = New System.Windows.Forms.Button()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.btnBigger = New System.Windows.Forms.Button()
Me.btnSmaller = New System.Windows.Forms.Button()
Me.pnlAutoScrollTest.SuspendLayout()
Me.SuspendLayout()
Me.pnlAutoScrollTest.AutoScroll = True
Me.pnlAutoScrollTest.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlAutoScrollTest.Controls.Add(Me.TextBox1)
Me.pnlAutoScrollTest.Location = New System.Drawing.Point(12, 12)
Me.pnlAutoScrollTest.Name = "pnlAutoScrollTest"
Me.pnlAutoScrollTest.Size = New System.Drawing.Size(210, 100)
Me.pnlAutoScrollTest.TabIndex = 0
Me.btnMoveLeft.Location = New System.Drawing.Point(12, 130)
Me.btnMoveLeft.Name = "btnMoveLeft"
Me.btnMoveLeft.Size = New System.Drawing.Size(102, 23)
Me.btnMoveLeft.TabIndex = 1
Me.btnMoveLeft.Text = "<< move left"
Me.btnMoveLeft.UseVisualStyleBackColor = True
Me.btnMoveRight.Location = New System.Drawing.Point(120, 130)
Me.btnMoveRight.Name = "btnMoveRight"
Me.btnMoveRight.Size = New System.Drawing.Size(102, 23)
Me.btnMoveRight.TabIndex = 1
Me.btnMoveRight.Text = "move right >>"
Me.btnMoveRight.UseVisualStyleBackColor = True
Me.TextBox1.Location = New System.Drawing.Point(22, 35)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(167, 20)
Me.TextBox1.TabIndex = 0
Me.btnBigger.Location = New System.Drawing.Point(67, 169)
Me.btnBigger.Name = "btnBigger"
Me.btnBigger.Size = New System.Drawing.Size(100, 23)
Me.btnBigger.TabIndex = 2
Me.btnBigger.Text = "<< Bigger >>"
Me.btnBigger.UseVisualStyleBackColor = True
Me.btnSmaller.Location = New System.Drawing.Point(67, 198)
Me.btnSmaller.Name = "btnSmaller"
Me.btnSmaller.Size = New System.Drawing.Size(100, 23)
Me.btnSmaller.TabIndex = 2
Me.btnSmaller.Text = ">> Smaller <<"
Me.btnSmaller.UseVisualStyleBackColor = True
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(232, 237)
Me.Controls.Add(Me.btnSmaller)
Me.Controls.Add(Me.btnBigger)
Me.Controls.Add(Me.btnMoveRight)
Me.Controls.Add(Me.btnMoveLeft)
Me.Controls.Add(Me.pnlAutoScrollTest)
Me.Name = "Form1"
Me.Text = "What !!??"
Me.pnlAutoScrollTest.ResumeLayout(False)
Me.pnlAutoScrollTest.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents pnlAutoScrollTest As System.Windows.Forms.Panel
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents btnMoveLeft As System.Windows.Forms.Button
Friend WithEvents btnMoveRight As System.Windows.Forms.Button
Friend WithEvents btnBigger As System.Windows.Forms.Button
Friend WithEvents btnSmaller As System.Windows.Forms.Button
#End Region
End Class