Public Class Form1
'递归控件
Sub RecursionControl(ByVal control As Control, ByVal resize As Boolean)
If control.HasChildren Then
Dim c As Control
For Each c In control.Controls
RecursionControl(c, resize)
Next
End If
If control IsNot Me Then
With control
If resize Then
Dim sp() As String = Split(Me.Tag, "|")
Dim scaleX As Single = Me.Width / Val(sp(0))
Dim scaleY As Single = Me.Height / Val(sp(1))
sp = Split(.Tag, "|")
.Left = scaleX * Val(sp(0))
.Top = scaleY * Val(sp(1))
.Width = scaleX * Val(sp(2))
.Height = scaleY * Val(sp(3))
Else
.Tag = .Left & "|" & .Top & "|" & .Width & "|" & .Height
End If
End With
End If
End Sub
Public Sub New()
' 此调用是 Windows 窗体设计器所必需的。
InitializeComponent()
' 在 InitializeComponent() 调用之后添加任何初始化。
Me.Tag = Me.Width & "|" & Me.Height
RecursionControl(Me, False)
End Sub
Private Sub Form2_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
RecursionControl(Me, True)
End Sub
End Class
以上代码在VB2005里面调试通过 ....