21-10-16, 04:40 AM
PHP كود :
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Panel1.AutoScroll = True
Dim frm2 As Form = New Form2
AddHandler frm2.LocationChanged, AddressOf Me.Form2_LocationChanged
AddHandler frm2.SizeChanged, AddressOf Me.Form2_SizeChanged
frm2.TopLevel = False
Me.Panel1.Controls.Add(frm2)
If frm2.Size.Width > Me.Panel1.Size.Width Or frm2.Size.Height > Me.Panel1.Size.Height Then
Me.SetAutoScrollMargin(frm2.Size.Width - Me.Panel1.Size.Width, frm2.Size.Height - Me.Panel1.Size.Height)
End If
frm2.Show()
End Sub
Private Sub Form2_LocationChanged(obj As Object, e As EventArgs)
Dim f As Form = CType(obj, Form)
Me.Panel1.SetAutoScrollMargin(f.Location.X, f.Location.Y)
End Sub
Private Sub Form2_SizeChanged(obj As Object, e As EventArgs)
Dim f As Form = CType(obj, Form)
If f.Size.Width > Me.Panel1.Size.Width Or f.Size.Height > Me.Panel1.Size.Height Then
Me.Panel1.SetAutoScrollMargin(Panel1.Size.Width - Panel1.Size.Width, f.Size.Height - Me.Size.Height)
Else
Me.Panel1.SetAutoScrollMargin(0, 0)
End If
End Sub

