16,550
社区成员
发帖
与我相关
我的任务
分享
Private Sub readAllItems(ob As Object)
If ob.GetType Is GetType(MenuStrip) Then
For Each m As Object In ob.Items
readAllItems(m)
Debug.Print(m.Name)'这里可读取,也可以在函数参数列表添加一个参数,把这个对象添加进
Next
End If
If ob.GetType Is GetType(ToolStripMenuItem) Then
For Each m As Object In ob.DropDownItems
readAllItems(m)
Debug.Print(m.Name)'同上
Next
End If
End Sub
调用:
readAllItems(MenuStrip1)’MenuStrip1为MenuStrip菜单类实例