Microsoft KB Archive/839577

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

Article ID: 839577

Article Last Modified on 5/18/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1

-





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 &quot;Applies to&quot; section. This problem was first corrected in the Microsoft .NET Framework 1.1 Service Pack 1.



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

The New Project dialog box appears. Under Project Types, click Visual Basic Projects. Under Templates, click Windows Control Library.</li> In the Name box, type testusercontrol, and then click OK.

By default, the file that is named Usercontrol1.vb appears.</li> Add a TextBox control to the Usercontrol1.vb [Design] file.</li> On the Build menu, click Build Solution.</li></ol> </li> Add a Windows application to the project. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> On the File menu, point to Add Project, and then click New Project.

The New Project dialog box appears.</li> Under Project Types, click Visual Basic Projects.</li> Under Templates, click Windows Application.</li> In the Name box, type user_control_scroll_UI, and then click OK.

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

The Add Reference dialog box appears.</li> Click the Projects tab, click Select, and then click OK to add the testusercontrol to your project reference.</li> Right-click the form that is named Form1, and then click View Code.</li>  Replace the existing code with the following code: Option Strict On Option Explicit On

Public Class MDIChild Inherits System.Windows.Forms.Form


 * 1) Region &quot; Windows Forms Designer generated code &quot;

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 = &quot;UserControl11&quot; 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 = &quot;TextBox1&quot; Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = &quot;TextBox1&quot; '       'TextBox2 '       Me.TextBox2.Location = New System.Drawing.Point(26, 384) Me.TextBox2.Name = &quot;TextBox2&quot; Me.TextBox2.Size = New System.Drawing.Size(103, 20) Me.TextBox2.TabIndex = 2 Me.TextBox2.Text = &quot;TextBox2&quot; '       'TextBox3 '       Me.TextBox3.Location = New System.Drawing.Point(26, 541) Me.TextBox3.Name = &quot;TextBox3&quot; Me.TextBox3.TabIndex = 3 Me.TextBox3.Text = &quot;TextBox3&quot; '       'TextBox4 '       Me.TextBox4.Location = New System.Drawing.Point(26, 725) Me.TextBox4.Name = &quot;TextBox4&quot; Me.TextBox4.TabIndex = 4 Me.TextBox4.Text = &quot;TextBox4&quot; '       'TextBox5 '       Me.TextBox5.Location = New System.Drawing.Point(26, 929) Me.TextBox5.Name = &quot;TextBox5&quot; Me.TextBox5.TabIndex = 5 Me.TextBox5.Text = &quot;TextBox5&quot; '       'TextBox6 '       Me.TextBox6.Location = New System.Drawing.Point(26, 1394) Me.TextBox6.Name = &quot;TextBox6&quot; Me.TextBox6.TabIndex = 7 Me.TextBox6.Text = &quot;TextBox6&quot; '       'UserControl12 '       Me.UserControl12.Location = New System.Drawing.Point(26, 1142) Me.UserControl12.Name = &quot;UserControl12&quot; 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 = &quot;MDIChild&quot; Me.Text = &quot;MDIChild&quot; Me.ResumeLayout(False)

End Sub


 * 1) End Region

End Class </li> 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.</li> In the Name box, type Mdi.vb, and then click Open.

The file that is named Mdi.vb appears.</li> In Solution Explorer, right-click the form that is named Mdi.vb, and then click View Code.</li>  Replace the existing code with the following code: Option Strict On Option Explicit On

Public Class MDI Inherits System.Windows.Forms.Form


 * 1) Region &quot; Windows Forms Designer generated code &quot;

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 = &quot;Load AutoScroll Child&quot; '       'mnuVScroll '       Me.mnuVScroll.Index = 1 Me.mnuVScroll.Text = &quot;Load VScroll Child&quot; '       '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 = &quot;MDI&quot; Me.Text = &quot;MDI&quot;

End Sub


 * 1) 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 </li> <li>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.</li> <li>In the Name box, type Vscroll.vb, and then click Open.

The file that is named Vscroll.vb appears.</li> <li>In Solution Explorer, right-click the form that is named Vscroll.vb, and then click View Code.</li> <li> Replace the existing code with the following code: ption Strict On Option Explicit On

Public Class VScrollChild Inherits System.Windows.Forms.Form


 * 1) Region &quot; Windows Forms Designer generated code &quot;

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 = &quot;testUcNum1&quot; 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 = &quot;TextBox1&quot; Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = &quot;TextBox1&quot; '       'TextBox2 '       Me.TextBox2.Location = New System.Drawing.Point(26, 384) Me.TextBox2.Name = &quot;TextBox2&quot; Me.TextBox2.Size = New System.Drawing.Size(103, 20) Me.TextBox2.TabIndex = 2 Me.TextBox2.Text = &quot;TextBox2&quot; '       'TextBox3 '       Me.TextBox3.Location = New System.Drawing.Point(26, 541) Me.TextBox3.Name = &quot;TextBox3&quot; Me.TextBox3.TabIndex = 3 Me.TextBox3.Text = &quot;TextBox3&quot; '       'TextBox4 '       Me.TextBox4.Location = New System.Drawing.Point(26, 725) Me.TextBox4.Name = &quot;TextBox4&quot; Me.TextBox4.TabIndex = 4 Me.TextBox4.Text = &quot;TextBox4&quot; '       'TextBox5 '       Me.TextBox5.Location = New System.Drawing.Point(26, 929) Me.TextBox5.Name = &quot;TextBox5&quot; Me.TextBox5.TabIndex = 5 Me.TextBox5.Text = &quot;TextBox5&quot; '       'TextBox6 '       Me.TextBox6.Location = New System.Drawing.Point(26, 1394) Me.TextBox6.Name = &quot;TextBox6&quot; Me.TextBox6.TabIndex = 7 Me.TextBox6.Text = &quot;TextBox6&quot; '       '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 = &quot;VScrollBar1&quot; 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 = &quot;testUcNum2&quot; 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 = &quot;VScrollChild&quot; Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show Me.Text = &quot;MDIChild&quot; Me.ResumeLayout(False)

End Sub


 * 1) 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 &quot;topLine&quot; 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(&quot;MDIChild_Load => Ctl Name: &quot; & ctl.Name & &quot;, Top=&quot; & 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(&quot;*** VScrollBar1_Scroll event fired! (New Value: &quot; & e.NewValue & &quot;)&quot;) 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(&quot;>>> Percentage Scroll: &quot; & Format(pct, &quot;00.0%&quot;) & &quot; <<<&quot;) Dim incr As Integer = CInt(pct * bottomLine) 'Debug.WriteLine(&quot;>>> Increment value: &quot; & incr & &quot; <<<&quot;)

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(&quot;VScrollBar1_Scroll => Ctl Name: &quot; & ctl.Name & &quot;, Top=&quot; & ctl.Top) End If       Next End Sub

End Class </li></ol> </li> <li>Build the solution, and then run the project. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>In Solution Explorer, click Solution 'testusercontrol' (2 projects).</li> <li>On the Project menu, click Properties.

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

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

The MDI form appears.</li> <li>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 &quot;Symptoms&quot; section.</li></ol> </li></ol>

<div class="references_section">