FIX: You cannot scroll down an MDI child form by clicking the scroll-down arrow

Article translations Article translations
Article ID: 839577 - View products that this article applies to.
Expand all | Collapse all

On This Page

SYMPTOMS

When a user control is present on a Multiple Document Interface (MDI) child form, you cannot scroll down. This problem occurs when the user control contains the focus. You try to scroll down by using the scroll-down arrow on the scroll bar of the child form, but you cannot scroll down.

CAUSE

When a user control contains the focus, the user control is an active control. However, when the user control contains the focus, the ActiveControl.Focused property that is present in the Microsoft .NET Framework 1.1 returns False instead of returning True. Therefore, focusing the user control forces the form to make the user control visible. This problem occurs when you perform a scroll-down operation by clicking the scroll-down arrow.

RESOLUTION

To resolve this problem, obtain the latest service pack for the Microsoft .NET Framework 1.1. The following file is available for download from the Microsoft Download Center:

The Microsoft .NET Framework 1.1 Service Pack 1
http://www.microsoft.com/downloads/details.aspx?FamilyId=A8F5654F-088E-40B2-BBDB-A83353618B38

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. This problem was first corrected in the Microsoft .NET Framework 1.1 Service Pack 1.

MORE INFORMATION

Steps to reproduce the problem

  1. Create a user control file. To do this, follow these steps:
    1. Start Microsoft Visual Studio .NET.
    2. On the File menu, point to New, and then click Project.

      The New Project dialog box appears.
    3. Under Project Types, click Visual Basic Projects.
    4. Under Templates, click Windows Control Library.
    5. In the Name box, type testusercontrol, and then click OK.

      By default, the file that is named Usercontrol1.vb appears.
    6. Add a TextBox control to the Usercontrol1.vb [Design] file.
    7. On the Build menu, click Build Solution.
  2. Add a Windows application to the project. To do this, follow these steps:
    1. On the File menu, point to Add Project, and then click New Project.

      The New Project dialog box appears.
    2. Under Project Types, click Visual Basic Projects.
    3. Under Templates, click Windows Application.
    4. In the Name box, type user_control_scroll_UI, and then click OK.

      By default, the form that is named Form1 appears.
    5. In Solution Explorer, right-click user_control_scroll_UI, and then click Add Reference.

      The Add Reference dialog box appears.
    6. Click the Projects tab, click Select, and then click OK to add the testusercontrol to your project reference.
    7. Right-click the form that is named Form1, and then click View Code.
    8. Replace the existing code with the following code:
      Option Strict On
      Option Explicit On 
      
      Public Class MDIChild
          Inherits System.Windows.Forms.Form
      
      #Region " Windows Forms Designer generated code "
      
          Public Sub New()
              MyBase.New()
      
              'This call is required by the Windows Forms Designer.
              InitializeComponent()
      
              'Add any initialization after the InitializeComponent() call.
      
          End Sub
      
          'The Form overrides dispose to clean up the component list.
          Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
              If disposing Then
                  If Not (components Is Nothing) Then
                      components.Dispose()
                  End If
              End If
              MyBase.Dispose(disposing)
          End Sub
      
          'This is required by the Windows Forms Designer.
          Private components As System.ComponentModel.IContainer
      
          'Note The following procedure is required by the Windows Forms Designer.
          'The following procedure can be modified by using the Windows Forms Designer.  
          'Do not modify the following procedure by using the code editor.
          Friend WithEvents UserControl11 As testusercontrol.UserControl1
          Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
          Friend WithEvents UserControl12 As testusercontrol.UserControl1
          <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
              Me.UserControl11 = New testusercontrol.UserControl1
              Me.TextBox1 = New System.Windows.Forms.TextBox
              Me.TextBox2 = New System.Windows.Forms.TextBox
              Me.TextBox3 = New System.Windows.Forms.TextBox
              Me.TextBox4 = New System.Windows.Forms.TextBox
              Me.TextBox5 = New System.Windows.Forms.TextBox
              Me.TextBox6 = New System.Windows.Forms.TextBox
              Me.UserControl12 = New testusercontrol.UserControl1
              Me.SuspendLayout()
              '
              'UserControl11
              '
              Me.UserControl11.Location = New System.Drawing.Point(26, 30)
              Me.UserControl11.Name = "UserControl11"
              Me.UserControl11.Size = New System.Drawing.Size(104, 24)
              Me.UserControl11.TabIndex = 0
              '
              'TextBox1
              '
              Me.TextBox1.Location = New System.Drawing.Point(26, 161)
              Me.TextBox1.Name = "TextBox1"
              Me.TextBox1.TabIndex = 1
              Me.TextBox1.Text = "TextBox1"
              '
              'TextBox2
              '
              Me.TextBox2.Location = New System.Drawing.Point(26, 384)
              Me.TextBox2.Name = "TextBox2"
              Me.TextBox2.Size = New System.Drawing.Size(103, 20)
              Me.TextBox2.TabIndex = 2
              Me.TextBox2.Text = "TextBox2"
              '
              'TextBox3
              '
              Me.TextBox3.Location = New System.Drawing.Point(26, 541)
              Me.TextBox3.Name = "TextBox3"
              Me.TextBox3.TabIndex = 3
              Me.TextBox3.Text = "TextBox3"
              '
              'TextBox4
              '
              Me.TextBox4.Location = New System.Drawing.Point(26, 725)
              Me.TextBox4.Name = "TextBox4"
              Me.TextBox4.TabIndex = 4
              Me.TextBox4.Text = "TextBox4"
              '
              'TextBox5
              '
              Me.TextBox5.Location = New System.Drawing.Point(26, 929)
              Me.TextBox5.Name = "TextBox5"
              Me.TextBox5.TabIndex = 5
              Me.TextBox5.Text = "TextBox5"
              '
              'TextBox6
              '
              Me.TextBox6.Location = New System.Drawing.Point(26, 1394)
              Me.TextBox6.Name = "TextBox6"
              Me.TextBox6.TabIndex = 7
              Me.TextBox6.Text = "TextBox6"
              '
              'UserControl12
              '
              Me.UserControl12.Location = New System.Drawing.Point(26, 1142)
              Me.UserControl12.Name = "UserControl12"
              Me.UserControl12.Size = New System.Drawing.Size(103, 27)
              Me.UserControl12.TabIndex = 6
              '
              'MDIChild
              '
              Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
              Me.AutoScroll = True
              Me.ClientSize = New System.Drawing.Size(275, 266)
              Me.Controls.Add(Me.UserControl12)
              Me.Controls.Add(Me.TextBox6)
              Me.Controls.Add(Me.TextBox5)
              Me.Controls.Add(Me.TextBox4)
              Me.Controls.Add(Me.TextBox3)
              Me.Controls.Add(Me.TextBox2)
              Me.Controls.Add(Me.TextBox1)
              Me.Controls.Add(Me.UserControl11)
              Me.Name = "MDIChild"
              Me.Text = "MDIChild"
              Me.ResumeLayout(False)
      
          End Sub
      
      #End Region
      
      End Class
      
    9. In Solution Explorer, right-click user_control_scroll_UI, point to Add, and then click Add New Item.

      The Add New Item - user_control_scroll_UI dialog box appears.
    10. In the Name box, type Mdi.vb, and then click Open.

      The file that is named Mdi.vb appears.
    11. In Solution Explorer, right-click the form that is named Mdi.vb, and then click View Code.
    12. Replace the existing code with the following code:
      Option Strict On
      Option Explicit On 
      
      Public Class MDI
          Inherits System.Windows.Forms.Form
      
      #Region " Windows Forms Designer generated code "
      
          Public Sub New()
              MyBase.New()
      
              'This call is required by the Windows Forms Designer.
              InitializeComponent()
      
              'Add any initialization after the InitializeComponent() call.
      
          End Sub
      
          'The Form overrides dispose to clean up the component list.
          Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
              If disposing Then
                  If Not (components Is Nothing) Then
                      components.Dispose()
                  End If
              End If
              MyBase.Dispose(disposing)
          End Sub
      
          'This is required by the Windows Forms Designer.
          Private components As System.ComponentModel.IContainer
      
          'Note The following procedure is required by the Windows Forms Designer
          'The following procedure can be modified by using the Windows Forms Designer.  
          'Do not modify the following procedure by using the code editor.
          Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
          Friend WithEvents mnuAutoScroll As System.Windows.Forms.MenuItem
          Friend WithEvents mnuVScroll As System.Windows.Forms.MenuItem
          <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
              Me.MainMenu1 = New System.Windows.Forms.MainMenu
              Me.mnuAutoScroll = New System.Windows.Forms.MenuItem
              Me.mnuVScroll = New System.Windows.Forms.MenuItem
              '
              'MainMenu1
              '
              Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuAutoScroll, Me.mnuVScroll})
              '
              'mnuAutoScroll
              '
              Me.mnuAutoScroll.Index = 0
              Me.mnuAutoScroll.Text = "Load AutoScroll Child"
              '
              'mnuVScroll
              '
              Me.mnuVScroll.Index = 1
              Me.mnuVScroll.Text = "Load VScroll Child"
              '
              'MDI
              '
              Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
              Me.ClientSize = New System.Drawing.Size(366, 299)
              Me.IsMdiContainer = True
              Me.Menu = Me.MainMenu1
              Me.Name = "MDI"
              Me.Text = "MDI"
      
          End Sub
      
      #End Region
      
      
          Private Sub MDI_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
          End Sub
      
          Private Sub mnuAutoScroll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAutoScroll.Click
              Dim currentForm As New MDIChild
      
              currentForm.MdiParent = Me
              currentForm.WindowState = FormWindowState.Maximized
              currentForm.Show()
              currentForm.BringToFront()
          End Sub
      
          Private Sub mnuVScroll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuVScroll.Click
              Dim currentForm As New VScrollChild
      
              currentForm.MdiParent = Me
              currentForm.WindowState = FormWindowState.Maximized
              currentForm.Show()
              currentForm.BringToFront()
          End Sub
      End Class
      
    13. In Solution Explorer, right-click user_control_scroll_UI, point to Add, and then click Add New Item.

      The Add New Item - user_control_scroll_UI dialog box appears.
    14. In the Name box, type Vscroll.vb, and then click Open.

      The file that is named Vscroll.vb appears.
    15. In Solution Explorer, right-click the form that is named Vscroll.vb, and then click View Code.
    16. Replace the existing code with the following code:
      ption Strict On
      Option Explicit On 
      
      Public Class VScrollChild
          Inherits System.Windows.Forms.Form
      
      #Region " Windows Forms Designer generated code "
      
          Public Sub New()
              MyBase.New()
      
              'This call is required by the Windows Forms Designer.
              InitializeComponent()
      
              'Add any initialization after the InitializeComponent() call.
      
          End Sub
      
          'The form overrides dispose to clean up the component list.
          Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
              If disposing Then
                  If Not (components Is Nothing) Then
                      components.Dispose()
                  End If
              End If
              MyBase.Dispose(disposing)
          End Sub
      
          'This is required by the Windows Forms Designer.
          Private components As System.ComponentModel.IContainer
      
          'Note The following procedure is required by the Windows Forms Designer.
          'The following procedure can be modified by using the Windows Forms Designer.  
          'Do not modify the following procedure by using the code editor.
          Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
          Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
          Friend WithEvents testUcNum1 As testusercontrol.UserControl1
          Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar
          Friend WithEvents testUcNum2 As testusercontrol.UserControl1
          <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
              Me.testUcNum1 = New testusercontrol.UserControl1
              Me.TextBox1 = New System.Windows.Forms.TextBox
              Me.TextBox2 = New System.Windows.Forms.TextBox
              Me.TextBox3 = New System.Windows.Forms.TextBox
              Me.TextBox4 = New System.Windows.Forms.TextBox
              Me.TextBox5 = New System.Windows.Forms.TextBox
              Me.TextBox6 = New System.Windows.Forms.TextBox
              Me.VScrollBar1 = New System.Windows.Forms.VScrollBar
              Me.testUcNum2 = New testusercontrol.UserControl1
              Me.SuspendLayout()
              '
              'testUcNum1
              '
              Me.testUcNum1.Location = New System.Drawing.Point(26, 30)
              Me.testUcNum1.Name = "testUcNum1"
              Me.testUcNum1.Size = New System.Drawing.Size(104, 24)
              Me.testUcNum1.TabIndex = 0
              '
              'TextBox1
              '
              Me.TextBox1.Location = New System.Drawing.Point(26, 161)
              Me.TextBox1.Name = "TextBox1"
              Me.TextBox1.TabIndex = 1
              Me.TextBox1.Text = "TextBox1"
              '
              'TextBox2
              '
              Me.TextBox2.Location = New System.Drawing.Point(26, 384)
              Me.TextBox2.Name = "TextBox2"
              Me.TextBox2.Size = New System.Drawing.Size(103, 20)
              Me.TextBox2.TabIndex = 2
              Me.TextBox2.Text = "TextBox2"
              '
              'TextBox3
              '
              Me.TextBox3.Location = New System.Drawing.Point(26, 541)
              Me.TextBox3.Name = "TextBox3"
              Me.TextBox3.TabIndex = 3
              Me.TextBox3.Text = "TextBox3"
              '
              'TextBox4
              '
              Me.TextBox4.Location = New System.Drawing.Point(26, 725)
              Me.TextBox4.Name = "TextBox4"
              Me.TextBox4.TabIndex = 4
              Me.TextBox4.Text = "TextBox4"
              '
              'TextBox5
              '
              Me.TextBox5.Location = New System.Drawing.Point(26, 929)
              Me.TextBox5.Name = "TextBox5"
              Me.TextBox5.TabIndex = 5
              Me.TextBox5.Text = "TextBox5"
              '
              'TextBox6
              '
              Me.TextBox6.Location = New System.Drawing.Point(26, 1394)
              Me.TextBox6.Name = "TextBox6"
              Me.TextBox6.TabIndex = 7
              Me.TextBox6.Text = "TextBox6"
              '
              'VScrollBar1
              '
              Me.VScrollBar1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                          Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
              Me.VScrollBar1.Location = New System.Drawing.Point(224, 0)
              Me.VScrollBar1.Name = "VScrollBar1"
              Me.VScrollBar1.Size = New System.Drawing.Size(17, 266)
              Me.VScrollBar1.TabIndex = 8
              '
              'testUcNum2
              '
              Me.testUcNum2.Location = New System.Drawing.Point(27, 639)
              Me.testUcNum2.Name = "testUcNum2"
              Me.testUcNum2.Size = New System.Drawing.Size(104, 24)
              Me.testUcNum2.TabIndex = 9
              '
              'VScrollChild
              '
              Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
              Me.ClientSize = New System.Drawing.Size(241, 266)
              Me.Controls.Add(Me.testUcNum2)
              Me.Controls.Add(Me.VScrollBar1)
              Me.Controls.Add(Me.TextBox6)
              Me.Controls.Add(Me.TextBox5)
              Me.Controls.Add(Me.TextBox4)
              Me.Controls.Add(Me.TextBox3)
              Me.Controls.Add(Me.TextBox2)
              Me.Controls.Add(Me.TextBox1)
              Me.Controls.Add(Me.testUcNum1)
              Me.Name = "VScrollChild"
              Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show
              Me.Text = "MDIChild"
              Me.ResumeLayout(False)
      
          End Sub
      
      #End Region
      
          Private htControlTops As New Hashtable
      
          'Note The following assumes that no controls are put above the form the first time. For example, there are no negative .Top values.
          '      If this is not the case, a similar "topLine" variable is required to make sure that 
          '      you know the full length of the useful area of the form.
          '                            bottomMostCtl.Top + bottomMostCtl.Height - topMostCtl.Top
          '      This calculation is not required on this form.
          Private bottomLine As Integer = Integer.MinValue
      
          Private Sub MDIChild_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
              For Each ctl As Control In Me.Controls
                  If TypeOf ctl Is testusercontrol.UserControl1 _
                      OrElse TypeOf ctl Is TextBox Then
      
                      htControlTops.Add(ctl.Name, ctl.Top)
                      Debug.WriteLine("MDIChild_Load => Ctl Name: " & ctl.Name & ", Top=" & ctl.Top)
      
                      If (ctl.Top + ctl.Height) > bottomLine Then
                          bottomLine = ctl.Top + ctl.Height
                      End If
                  End If
              Next
          End Sub
      
          Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
              Debug.WriteLine("*** VScrollBar1_Scroll event fired! (New Value: " & e.NewValue & ")")
              ScrollForMe(e.NewValue)
          End Sub
      
          Private Sub ScrollForMe(ByVal scrollValue As Integer)
              Dim oldTop As Integer
              Dim pct As Double = scrollValue / VScrollBar1.Maximum
              'Debug.WriteLine(">>> Percentage Scroll: " & Format(pct, "00.0%") & " <<<")
              Dim incr As Integer = CInt(pct * bottomLine)
              'Debug.WriteLine(">>> Increment value: " & incr & " <<<")
      
              For Each ctl As Control In Me.Controls
                  If TypeOf ctl Is testusercontrol.UserControl1 _
                      OrElse TypeOf ctl Is TextBox Then
      
                      oldTop = CType(htControlTops(ctl.Name), Integer)
                      ctl.Top = oldTop - incr
                      'Debug.WriteLine("VScrollBar1_Scroll => Ctl Name: " & ctl.Name & ", Top=" & ctl.Top)
                  End If
              Next
          End Sub
      
      End Class
      
  3. Build the solution, and then run the project. To do this, follow these steps:
    1. In Solution Explorer, click Solution 'testusercontrol' (2 projects).
    2. On the Project menu, click Properties.

      The Solution 'testusercontrol' Property Pages dialog box appears.
    3. In the left pane, double-click Startup Project under Common Properties, and then click user_control_scroll_UI.
    4. In the left pane, double-click Project Dependencies under Common Properties.
    5. In the right pane, click testusercontrol in the Project list, and then click OK.
    6. In Solution Explorer, right-click user_control_scroll_UI, and then click Properties.

      The user_control_scroll_UI Property Pages dialog box appears.
    7. In the left pane, double-click General under Common Properties.
    8. In the right pane, click MDI in the Startup object box.
    9. On the Build menu, click Build Solution.
    10. Press F5 to run the program.

      The MDI form appears.
    11. Click Load AutoScroll Child, click the scroll-down arrow to try to move through the form.

      You notice the behavior that is mentioned in the "Symptoms" section.

REFERENCES

For additional information about creating MDI child forms, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/aa984329(VS.71).aspx
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
824684Description of the standard terminology that is used to describe Microsoft software updates

Properties

Article ID: 839577 - Last Review: May 18, 2007 - Revision: 2.2
APPLIES TO
  • Microsoft .NET Framework 1.1
Keywords: 
kbqfe kbhotfixserver kbmdi kbnetframe110sp1fix kbscrollbar kbcontrol kbforms kbbug kbfix kbnetframe110presp1fix KB839577

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com