Panel scrollbars reset when control receives focus

G

Guest

Hope this is the right place for this question. I'm using VB.Net 2003 and
have a Panel with it's Autoscroll property set to true that contains an
undocked panel. When this second panel is larger than it's 'parent', it's
parent shows scrollbars. However, if the second panel receives focus, the
scrollbars in it's parent window reset to their default position. Is there a
way to stop this from happening?

Thanks,
 
G

Guest

The following is an example of the problem. If you move the scroll bars,
then click in the text box, then click in the panel, the scroll bars go back
to their original position.

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim FirstPanel As New Panel, SecondPanel As New Panel, aTextBox As
New TextBox
FirstPanel.Location = New Point(0, 0)
FirstPanel.Size = New Size(200, 200)
FirstPanel.AutoScroll = True
FirstPanel.BackColor = Color.White
Me.Controls.Add(FirstPanel)

SecondPanel.Location = New Point(0, 0)
SecondPanel.Size = New Size(400, 400)
SecondPanel.BackColor = Color.White
AddHandler SecondPanel.Click, AddressOf SecondPanel_Click
FirstPanel.Controls.Add(SecondPanel)

aTextBox.Location = New Point(50, 250)
Me.Controls.Add(aTextBox)
End Sub

Private Sub SecondPanel_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
CType(sender, Panel).Focus()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top