Sub FindControl(ByVal Ctrls As Control)
For Each C As Control In Ctrls.Controls
MessageBox.Show(C.Name)
If C.HasChildren Then
FindControl(C)
End If
Next
End Sub
本文提供了一个简单的VB.NET代码片段,展示了如何使用递归函数SubFindControl遍历指定控件集合,逐个显示每个控件的名称,并在存在子控件的情况下继续遍历其子控件。
Sub FindControl(ByVal Ctrls As Control)
For Each C As Control In Ctrls.Controls
MessageBox.Show(C.Name)
If C.HasChildren Then
FindControl(C)
End If
Next
End Sub
955
614
5801

被折叠的 条评论
为什么被折叠?
