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
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
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
Microsoft Knowledge Base の免責: Microsoft Knowledge Baseに含まれている情報は、いかなる保証もない現状ベースで提供されるものです。Microsoft Corporation及びその関連会社は、市場性および特定の目的への適合性を含めて、明示的にも黙示的にも、一切の保証をいたしません。さらに、Microsoft Corporation及びその関連会社は、本文書に含まれている情報の使用及び使用結果につき、正確性、真実性等、いかなる表明・保証も行ないません。Microsoft Corporation、その関連会社及びこれらの権限ある代理人による口頭または書面による一切の情報提供またはアドバイスは、保証を意味するものではなく、かつ上記免責条項の範囲を狭めるものではありません。Microsoft Corporation、その関連会社 及びこれらの者の供給者は、直接的、間接的、偶発的、結果的損害、逸失利益、懲罰的損害、または特別損害を含む全ての損害に対して、状況のいかんを問わず一切責任を負いません。(Microsoft Corporation、その関連会社 またはこれらの者の供給者がかかる損害の発生可能性を了知している場合を含みます。) 結果的損害または偶発的損害に対する責任の免除または制限を認めていない地域においては、上記制限が適用されない場合があります。なお、本文書においては、文書の体裁上の都合により製品名の表記において商標登録表示、その他の商標表示を省略している場合がありますので、予めご了解ください。