Wanneer een besturingselement op meerdere documenten aanwezig is
Interface (MDI) onderliggend formulier u
kan niet schuiven. Dit probleem treedt op wanneer het besturingselement de focus bevat. Probeer te schuiven
omlaag met de pijl omlaag schuiven op de schuifbalk kan niet balk van het onderliggende formulier, maar schuiven.
Wanneer een besturingselement de focus bevat, is het besturingselement een actieve
besturingselement. Echter, wanneer het besturingselement de focus bevat deActiveControl.Focusedeigenschap van Microsoft.NET Framework 1.1
retourneert onwaar in plaats van True te retourneren. De gebruiker daarom concentreren
besturingselement formulier zichtbaar maken van het besturingselement afgedwongen. Dit probleem treedt op wanneer u een
Scroll omlaag bewerking door op de pijl omlaag schuiven.
Om dit probleem oplossen door het meest recente servicepack voor verkrijgen
Microsoft.NET Framework 1.1.Het volgende bestand is gedownload van het Microsoft Downloadcentrum:
Microsoft heeft bevestigd dat dit probleem in de Microsoft-producten die worden vermeld in de sectie 'Van toepassing op' is. Dit probleem is gecorrigeerd in Microsoft.NET
Framework 1.1 servicepack 1.
Bestand met een besturingselement maken. U doet dit als volgt:
Start Microsoft Visual Studio.NET.
Op deBestandin het menuNieuwe, en klik vervolgens opProject.
DeNieuwe
Projecthet dialoogvenster weergegeven.
OnderProjecttypen, klik opVisual Basic-projecten.
OnderSjablonen, klik opWindows
Bibliotheek voor besturingselementen.
In deNaamin het vaktestusercontrol, en klik vervolgens opOK.
Door
Standaard wordt het bestand met de naam Usercontrol1.vb.
Toevoegen eenTextBoxbepalen de Usercontrol1.vb
Bestand [ontwerp].
Op deBouwenmenu, klik opBouwen
Oplossing.
Een Windows-toepassing aan het project toevoegen. U doet dit als volgt:
Op deBestandin het menuToevoegen
Project, en klik vervolgens opNieuw Project.
DeNieuwe
Projecthet dialoogvenster weergegeven.
OnderProjecttypen, klik opVisual Basic
Projecten.
OnderSjablonen, klik opWindows
Toepassing.
In deNaamin het vakuser_control_scroll_UI, en klik vervolgens opOK.
Standaard verschijnt het formulier met de naam Form1.
In de Solution Explorer met de rechtermuisknopuser_control_scroll_UI, en klik vervolgens opToevoegen
Verwijzing.
DeVerwijzing toevoegenhet dialoogvenster
wordt weergegeven.
Klik op deProjectenen klik opSelecteer, en klik vervolgens opOKtoevoegen de
testusercontrol de verwijzing naar het project.
Klik met de rechtermuisknop op het formulier met de naamFormulier1, en klik vervolgens opWeergave
Code.
Bestaande code vervangen door de volgende 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
In de Solution Explorer met de rechtermuisknopuser_control_scroll_UI, wijsToevoegen, en
Klik vervolgens opNieuw Item toevoegen.
In deNaamin het vakMDI.VB, en klik vervolgens opOpen.
Het bestand met de naam Mdi.vb wordt weergegeven.
In de Solution Explorer met de rechtermuisknop op de
formulier met de naamMDI.VB, en klik vervolgens opWeergave
Code.
Bestaande code vervangen door de volgende 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
In de Solution Explorer met de rechtermuisknopuser_control_scroll_UI, wijsToevoegen, en
Klik vervolgens opNieuw Item toevoegen.
In deNaamin het vakVscroll.VB, en klik vervolgens opOpen.
De
bestand met de naam Vscroll.vb wordt weergegeven.
In de Solution Explorer met de rechtermuisknop op de
formulier met de naamVscroll.VB, en klik vervolgens opWeergave
Code.
Bestaande code vervangen door de volgende 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
De oplossing bouwen en uitvoeren van het project. U doet dit als volgt:
Klik in de Solution Explorer'Testusercontrol' (2 projecten) oplossing.
Op deProjectmenu, klik opEigenschappen.
DeEigenschap ' testusercontrol'-oplossing
Pagina 'shet dialoogvenster weergegeven.
Dubbelklik in het linkerdeelvenster opOpstartprojectonderAlgemene
Eigenschappen, en klik vervolgens opuser_control_scroll_UI.
Dubbelklik in het linkerdeelvenster opProject
AfhankelijkhedenonderAlgemene
Eigenschappen.
Klik in het rechterdeelvenster optestusercontrolin deProjectlijst, en
Klik vervolgens opOK.
In de Solution Explorer met de rechtermuisknopuser_control_scroll_UI, en klik vervolgens opEigenschappen.
Deuser_control_scroll_UI, eigenschap
Pagina 'shet dialoogvenster weergegeven.
Dubbelklik in het linkerdeelvenster opAlgemeenonderAlgemene
Eigenschappen.
Klik in het rechterdeelvenster opMDIin deOpstarten-objectvak.
Op deBouwenmenu, klik opBouwen
Oplossing.
Druk op F5 om het programma uitvoeren.
DeMDIformulier weergegeven.
Klik opAutoScroll onderliggende laden, klik op de
pijl omlaag schuiven om te verplaatsen via het formulier.
Ziet u het gedrag dat
vermeld in de sectie 'Symptomen'.
BELANGRIJK: Dit artikel is vertaald door de vertaalmachine software van Microsoft in plaats van door een professionele vertaler. Microsoft biedt u professioneel vertaalde artikelen en artikelen vertaald door de vertaalmachine, zodat u toegang heeft tot al onze knowledge base artikelen in uw eigen taal. Artikelen vertaald door de vertaalmachine zijn niet altijd perfect vertaald. Deze artikelen kunnen fouten bevatten in de vocabulaire, zinsopbouw en grammatica en kunnen lijken op hoe een anderstalige de taal spreekt en schrijft. Microsoft is niet verantwoordelijk voor onnauwkeurigheden, fouten en schade ontstaan door een incorrecte vertaling van de content of het gebruik ervan door onze klanten. Microsoft past continue de kwaliteit van de vertaalmachine software aan door deze te updaten.
De Engelstalige versie van dit artikel is de volgende:839577
Dank u! Uw feedback wordt gebruikt om ons te helpen onze inhoud voor ondersteuning te verbeteren. Bezoek de Startpagina voor Hulp en ondersteuning voor meer assistentieopties.