遍历组件

既然所有的菜单都是派生自RibbonMenu.RibbonItem类型,所以这个类型的变量可以引用任何类型的组件,例如:

Dim itm1 As RibbonMenu.RibbonItem
Dim
itm2 As RibbonMenu.RibbonItem
itm1 = RibbonTabs("Common").Groups("ClipBoard").Items("Paste")
itm2 = RibbonTabs(
"Print").Groups("QuickSetting").Items("OnlySelected"
)

如果要遍历容器中的所有控件,只能使用RibbonMenu.RibbonItem类型的变量,例如:

Dim itm As RibbonMenu.RibbonItem
For Each
itm In RibbonTabs("Table").Groups("Table").Items
    itm.Enabled =
False
Next

如果要遍历特定类型的控件,可以用Typeof 判断控件类型,例如:

Dim itm As RibbonMenu.RibbonItem
For Each
itm In RibbonTabs("Table").Groups("Column").Items
   
If Typeof itm Is RibbonMenu.Button Then
       
itm.Enabled = False
   
End If
Next

有关派生和判断类型的知识,在窗口设计的遍历控件一节有详细的介绍,大家可以温习一下。


本页地址:http://www.foxtable.com/webhelp/topics/1926.htm